[-]
[+]
|
Changed |
cego.changes
|
|
[-]
[+]
|
Changed |
cego.spec
^
|
|
[-]
[+]
|
Deleted |
cego-2.15.2.tar.bz2/tools/cgrecover~
^
|
@@ -1,48 +0,0 @@
-#!/bin/bash
-#
-# cgrecover
-# --------
-# utility for recover a tableset from an online backup
-#
-# Design and Implementation by Bjoern Lemke
-#
-# (C)opyright 2009 Bjoern Lemke
-
-if [ -z $1 ] || [ -z $2 ]
-then
- echo "Usage : mkrecover <tableset> <recoverfile>"
- exit 1
-fi
-
-# please customize the following parameters
-TS=$1
-BUFILE=$2
-CGADM=cgadm
-USER=cgadm/cgadm
-HOST=localhost
-PORT=2000
-
-### end of customizing ####
-
-echo "Stopping tableset $TS .."
-
-$CGADM --server=$HOST --port=$PORT --user=$USER --cmd="stop tableset ${TS};"
-if [ $? -ne 0 ]
-then
- echo "Cannot stop tableset $TS"
- exit 1
-fi
-
-echo "Restoring datafiles .."
-tar -xvf $BUFILE
-
-$CGADM --server=$HOST --port=$PORT --user=$USER --cmd="recover tableset ${TS};"
-
-if [ $? -ne 0 ]
-then
- echo "Cannot recover tableset $TS"
- exit 1
-fi
-
-echo "Recovery completed."
-exit 0
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/README
^
|
@@ -4,7 +4,7 @@
----
A relational and transactional database system
- Version 2.15.2
+ Version 2.15.3
(C)opyright 2006,2007,2008,2009,2010,2011,2012 by Bjoern Lemke
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/samples/chkdb/cglogmng
^
|
@@ -2,17 +2,15 @@
ARCHFILE=$1
ARCHPATH=$2
-TAPEPATH=./arch
+TAPEPATH=./tape
for i in 1 2 3
do
-
if [ -e "$TAPEPATH/$ARCHFILE" ]
then
TARGETPATH=`echo $ARCHPATH | awk -F: '{ print $1 }'`
echo "Restoring $ARCHFILE ..."
- sleep 1
- # cp $TAPEPATH/$ARCHFILE $TARGETPATH
+ cp $TAPEPATH/$ARCHFILE $TARGETPATH
if [ $? -eq 0 ]
then
exit 0
@@ -20,8 +18,7 @@
exit 2
fi
fi
- echo "Waiting for log .."
- sleep 2
+ sleep 1
done
exit 1
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/samples/chkdb/cglogmng~
^
|
@@ -4,21 +4,25 @@
ARCHPATH=$2
TAPEPATH=./arch
-sleep 3
+for i in 1 2 3
+do
-if [ -e "$TAPEPATH/$ARCHFILE" ]
-then
- TARGETPATH=`echo $ARCHPATH | awk -F: '{ print $1 }'`
- echo "Restoring $ARCHFILE ..."
- sleep 1
- # cp $TAPEPATH/$ARCHFILE $TARGETPATH
- if [ $? -eq 0 ]
+ if [ -e "$TAPEPATH/$ARCHFILE" ]
then
- exit 0
- else
- exit 2
+ TARGETPATH=`echo $ARCHPATH | awk -F: '{ print $1 }'`
+ echo "Restoring $ARCHFILE ..."
+ sleep 1
+ # cp $TAPEPATH/$ARCHFILE $TARGETPATH
+ if [ $? -eq 0 ]
+ then
+ exit 0
+ else
+ exit 2
+ fi
fi
-else
- exit 1
-fi
+ echo "Waiting for log .."
+ sleep 2
+done
+
+exit 1
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/samples/chkdb/pid
^
|
@@ -1 +1 @@
-13496
\ No newline at end of file
+28360
\ No newline at end of file
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoAdmAction.cc
^
|
@@ -52,8 +52,6 @@
#define DEFTSTICKET "tsticket.xml"
#define DEFTIMEOUT 10
-#define PITFORMAT "%Y-%m-%d %H:%M:%S %Z"
-
#define MAXHOSTLEN 25
CegoAdmAction::CegoAdmAction(CegoAdminHandler *pAH, CegoModule *pModule, CegoAdmAction::ResultMode resultMode, bool rawMode)
@@ -171,7 +169,6 @@
}
-
void CegoAdmAction::setDefault()
{
_primary = DEFPRIMARY;
@@ -185,6 +182,11 @@
_tmpSize = DEFTMPSIZE;
}
+void CegoAdmAction::setPitFormat(const Chain& pitFormat)
+{
+ _pitFormat = pitFormat;
+}
+
/////////////////////////////////
// cego semantic action methods //
/////////////////////////////////
@@ -2668,7 +2670,7 @@
{
Chain* pS = getTokenList().First();
Chain dateVal = Chain(_stringBuf);
- Datetime dt(dateVal, PITFORMAT);
+ Datetime dt(dateVal, _pitFormat);
_pit = dt.asInt();
}
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoAdmAction.h
^
|
@@ -53,6 +53,7 @@
char nextChar();
void backChar();
+ void setPitFormat(const Chain& pitFormat);
void setDefault();
void printTokenList();
@@ -247,6 +248,8 @@
Chain _filterPerm;
Chain _rightPerm;
+ Chain _pitFormat;
+
unsigned long _modId;
ListT<CegoField> _admSchema;
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoAdmin.cc
^
|
@@ -71,6 +71,7 @@
#define DEFAULTSERVER "localhost"
#define DEFAULTPORT 2000
+#define DEFPITFORMAT "%Y-%m-%d %H:%M:%S"
#define HISTFILE ".cgadm_history"
#define PROMPT "CGADM > "
@@ -243,7 +244,15 @@
pModule->log(modId, Logger::LOGERR, Chain("Got session... "));
CegoAdmAction* pAdm = new CegoAdmAction(pAH, pModule, resultMode, rawMode);
-
+
+ Chain pitFormat(DEFPITFORMAT);
+ char *pPF = getenv("CGPITFORMAT");
+ if ( pPF )
+ {
+ pitFormat = Chain(pPF);
+ }
+ pAdm->setPitFormat(pitFormat);
+
int exitCode = 0;
try
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoAdminThread.cc
^
|
@@ -169,7 +169,7 @@
// _pTabMng->startRecoveryMode(tableSet);
CegoRecoveryManager recoveryMng(_pTabMng);
- recoveryMng.recoverTableSet(tableSet, 0, true, false);
+ long lsn = recoveryMng.recoverTableSet(tableSet, 0, true);
_pDBMng->decreaseActiveAdmThread();
_pPool->setState(_idx, CegoAdminThreadPool::READY);
@@ -3032,7 +3032,7 @@
pAH->getTableSet(tableSet);
pAH->getPit(pit);
CegoRecoveryManager recoveryMng(_pTabMng);
- long lsn = recoveryMng.recoverTableSet(tableSet, pit, true, true);
+ long lsn = recoveryMng.recoverTableSet(tableSet, pit, true);
pAH->sendResponse(Chain("Tableset recovered to lsn ") + Chain(lsn));
}
@@ -5220,7 +5220,7 @@
long lsn;
CegoRecoveryManager recoveryMng(_pTabMng);
- lsn = recoveryMng.recoverTableSet(tableSet, pit, true, true);
+ lsn = recoveryMng.recoverTableSet(tableSet, pit, true);
pAH->syncWithInfo(Chain("mediator"), mediator, Chain("Tableset recovered to lsn ") + Chain(lsn));
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoDefs.h
^
|
@@ -40,7 +40,7 @@
#endif
#define CEGO_PRODUCT "Cego"
-#define CEGO_VERSION "2.15.2"
+#define CEGO_VERSION "2.15.3"
#define CEGO_COPYRIGHT "Copyright (C) 2000-2012 by Bjoern Lemke. All rights reserved"
/*******************************/
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoLogManager.cc
^
|
@@ -85,7 +85,9 @@
Chain CegoLogManager::getArchiveLogName(const Chain& tableSet, long lsn)
{
- return tableSet + "-" + Chain(lsn) + ".dbf";
+ Chain lsnStr = Chain("000000000000") + Chain(lsn);
+ Chain lsnFix = lsnStr.subChain(lsnStr.length() - 12, lsnStr.length());
+ return tableSet + "-" + lsnFix + ".dbf";
}
void CegoLogManager::setLogFile(int tabSetId, const Chain& logFile, bool readOnly)
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoMain.cc
^
|
@@ -1527,7 +1527,9 @@
pBeatThread->beat();
ListT<Chain> actList;
- pDBMng->getActiveTableSet(h.getName(), actList);
+
+ // we get all active tableset, except the tablesets which actually are recovered
+ pDBMng->getActiveTableSet(h.getName(), actList, false);
if ( actList.Size() > 0 )
{
@@ -1536,7 +1538,7 @@
while ( pAct )
{
#ifdef CGDEBUG
- pDBMng->log(modId, Logger::DEBUG, Chain("Cleaning tableset ") + *pAct + Chain(" ..."));
+ pDBMng->log(modId, Logger::DEBUG, Chain("Checking tableset ") + *pAct + Chain(" ..."));
#endif
CegoDistManager tabMng(pDBMng);
@@ -1566,7 +1568,7 @@
pDBMng->log(modId, Logger::LOGERR, Chain("Main Thread : ") + exep);
}
#ifdef CGDEBUG
- pDBMng->log(modId, Logger::DEBUG, Chain("Tableset ") + *pAct + Chain(" cleaned"));
+ pDBMng->log(modId, Logger::DEBUG, Chain("Tableset ") + *pAct + Chain(" checked"));
#endif
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoRecoveryManager.cc
^
|
@@ -59,7 +59,7 @@
{
}
-long CegoRecoveryManager::recoverTableSet(const Chain& tableSet, int pit, bool waitForSync, bool treatOnlineLog)
+long CegoRecoveryManager::recoverTableSet(const Chain& tableSet, int pit, bool waitForSync)
{
_pLogger->log(_modId, Logger::NOTICE, Chain("Recovering tableset ") + tableSet + Chain(" ..."));
@@ -155,12 +155,11 @@
}
-
_pDBMng->log(_modId, Logger::NOTICE, Chain("Commited lsn = ") + Chain(cplsn));
try
{
- cplsn = transactionRecovery(tableSet, tabSetId, cplsn + 1, pit, treatOnlineLog);
+ cplsn = transactionRecovery(tableSet, tabSetId, cplsn + 1, pit);
}
catch ( Exception e )
{
@@ -314,7 +313,7 @@
}
}
-long CegoRecoveryManager::transactionRecovery(const Chain& tableSet, int tabSetId, long cplsn, int pit, bool treatOnlineLog)
+long CegoRecoveryManager::transactionRecovery(const Chain& tableSet, int tabSetId, long cplsn, int pit)
{
bool endOfRecovery = false;
Chain sourceFileName;
@@ -326,7 +325,7 @@
&& rstate != CegoRecoveryManager::RECPITREACHED
&& endOfRecovery == false)
{
-
+
bool fileFound = false;
while ( fileFound == false && endOfRecovery == false && _pDBMng->getRecoveryMode(tabSetId) == CegoDatabaseManager::ON )
@@ -410,55 +409,57 @@
}
}
}
- bool isRecovered = false;
- while ( fileFound && ! isRecovered && _pDBMng->getRecoveryMode(tabSetId) == CegoDatabaseManager::ON )
- {
-
- _pDBMng->log(_modId, Logger::NOTICE, Chain("Recovering offline logfile ") + sourceFileName + Chain(" ..."));
- _pDBMng->setLogFile(tabSetId, sourceFileName, true);
-
- _pDBMng->setLSN(tabSetId, cplsn + 1);
- long lsn;
-
- rstate = recoverCurrentTransactionLog(tabSetId, pit, lsn, ts);
+ if ( fileFound )
+ {
- if ( rstate == CegoRecoveryManager::RECOK )
- {
- _pDBMng->log(_modId, Logger::NOTICE, Chain("Transaction recovery ok"));
- cplsn = lsn;
- // _pGTM->writeCheckPoint(tableSet, false, false);
- isRecovered=true;
- }
- else if ( rstate == CegoRecoveryManager::RECINCOMPLETE )
- {
- _pDBMng->log(_modId, Logger::NOTICE, Chain("Incomplete offline logfile ") + sourceFileName + Chain(" detected, waiting ..."));
- Sleeper s;
- s.secSleep(LOGMNG_RECOVERY_DELAY);
- }
- else if ( rstate == CegoRecoveryManager::RECPITREACHED )
+ bool isRecovered = false;
+ while ( ! isRecovered && _pDBMng->getRecoveryMode(tabSetId) == CegoDatabaseManager::ON )
{
- _pDBMng->log(_modId, Logger::NOTICE, Chain("PIT reached"));
- }
- else
- {
- _pDBMng->log(_modId, Logger::NOTICE, Chain("Unknwon recovery state"));
+
+ _pDBMng->log(_modId, Logger::NOTICE, Chain("Recovering offline logfile ") + sourceFileName + Chain(" ..."));
+ _pDBMng->setLogFile(tabSetId, sourceFileName, true);
+
+ _pDBMng->setLSN(tabSetId, cplsn + 1);
+
+ rstate = recoverCurrentTransactionLog(tabSetId, pit, cplsn, ts);
+
+ if ( rstate == CegoRecoveryManager::RECOK )
+ {
+ _pDBMng->log(_modId, Logger::NOTICE, Chain("Transaction recovery ok"));
+ // cplsn = lsn;
+ // _pGTM->writeCheckPoint(tableSet, false, false);
+ isRecovered=true;
+ }
+ else if ( rstate == CegoRecoveryManager::RECINCOMPLETE )
+ {
+ _pDBMng->log(_modId, Logger::NOTICE, Chain("Incomplete offline logfile ") + sourceFileName + Chain(" detected, waiting ..."));
+ Sleeper s;
+ s.secSleep(LOGMNG_RECOVERY_DELAY);
+ }
+ else if ( rstate == CegoRecoveryManager::RECPITREACHED )
+ {
+ _pDBMng->log(_modId, Logger::NOTICE, Chain("PIT reached"));
+ isRecovered=true;
+ }
+ else
+ {
+ throw Exception(EXLOC, Chain("Unknwon recovery state"));
+ }
}
}
}
_pDBMng->log(_modId, Logger::NOTICE, Chain("Finished recovery loop ..."));
-
+ // after recovery mode has been finished, we still have to check for the last logfile to recover
if ( rstate == CegoRecoveryManager::RECINCOMPLETE )
{
- long lsn;
-
while ( rstate != CegoRecoveryManager::RECOK )
{
_pDBMng->log(_modId, Logger::NOTICE, Chain("Recovering final offline logfile ") + sourceFileName + Chain(" ..."));
- rstate = recoverCurrentTransactionLog(tabSetId, pit, lsn, ts);
+ rstate = recoverCurrentTransactionLog(tabSetId, pit, cplsn, ts);
if ( rstate == CegoRecoveryManager::RECINCOMPLETE )
{
@@ -466,63 +467,9 @@
Sleeper s;
s.secSleep(LOGMNG_RECOVERY_DELAY);
}
- }
-
- cplsn = lsn;
- // _pGTM->writeCheckPoint(tableSet, false, false);
-
+ }
}
-
- /*
- _pDBMng->log(_modId, Logger::NOTICE, Chain("Before online recovery lsn is ") + Chain(_pDBMng->getLSN(tabSetId)));
-
- if ( treatOnlineLog && rstate != RECPITREACHED )
- {
-
- ListT<Chain> lfList;
- ListT<int> sizeList;
- ListT<Chain> statusList;
-
- _pDBMng->getLogFileInfo(tableSet, lfList, sizeList, statusList);
-
- Chain *pLog = lfList.First();
-
- while ( pLog )
- {
-
- // check if appropriate
- _pDBMng->log(_modId, Logger::NOTICE, Chain("Checking online logfile ") + *pLog + Chain(" ..."));
- _pDBMng->setLogFile(tabSetId, *pLog, true);
-
- int minlsn = _pDBMng->getMinLSN(tabSetId);
-
- _pDBMng->log(_modId, Logger::NOTICE, Chain("MinLSN = ") + Chain(minlsn) + Chain(" CPLSN = ") + Chain(cplsn));
-
- if ( minlsn == ( cplsn + 1 ) )
- {
-
- _pDBMng->log(_modId, Logger::NOTICE, Chain("Recovering online logfile ") + *pLog + Chain(" ..."));
-
- _pDBMng->setLSN(tabSetId, cplsn + 1);
-
- long lsn;
- rstate = recoverCurrentTransactionLog(tabSetId, pit, lsn, ts);
- cplsn = lsn;
-
- // start again to search next appropriate log file
- pLog = lfList.First();
-
- }
- else // if ( minlsn != 0 && minlsn <= cplsn )
- {
- pLog = lfList.Next();
- }
- }
- }
- */
-
-
_pGTM->writeCheckPoint(tableSet, false, false);
return cplsn;
@@ -609,10 +556,10 @@
CegoRecoveryManager::RecoveryState CegoRecoveryManager::recoverCurrentTransactionLog(int tabSetId, int pit, long& lsn, int& ts)
{
- lsn=0;
- bool pitReached = false;
+ // lsn=0;
- RecoveryState rstate = CegoRecoveryManager::RECOK;
+ // initially, we set the logfile to incomplete
+ RecoveryState rstate = CegoRecoveryManager::RECINCOMPLETE;
_pDBMng->seekToStart(tabSetId);
@@ -621,17 +568,16 @@
// now recover to last lsn in log
SetT<Chain> invalidateSet;
-
CegoLogRecord logRec;
- while ( _pDBMng->logRead(tabSetId, logRec) && pitReached == false )
+ while ( _pDBMng->logRead(tabSetId, logRec) && rstate != CegoRecoveryManager::RECPITREACHED )
{
+ // point-in-time recovery
if ( pit > 0 && logRec.getTS() > pit )
{
Datetime d(logRec.getTS());
_pDBMng->log(_modId, Logger::NOTICE, Chain("Required point in time reached, Ignoring logentry ") + Chain(logRec.getLSN())
+ Chain(" ( ") + d.asChain() + Chain(" ) and higher"));
- pitReached = true;
rstate = CegoRecoveryManager::RECPITREACHED;
@@ -639,7 +585,6 @@
else if ( logRec.getTS() < ts )
{
_pDBMng->log(_modId, Logger::NOTICE, Chain("Old log detected, ignoring logentry ") + Chain(logRec.getLSN()) + Chain(" and higher"));
- pitReached = true;
rstate = CegoRecoveryManager::RECPITREACHED;
@@ -649,6 +594,9 @@
if ( logRec.getLSN() == _pDBMng->getLSN(tabSetId) )
{
+ // we got a valid lsn, so the log file seems to be complete and we can switch from incomplete to ok
+ rstate = CegoRecoveryManager::RECOK;
+
lsn=logRec.getLSN();
ts=logRec.getTS();
int tid=logRec.getTID();
@@ -924,7 +872,6 @@
_pDBMng->log(_modId, Logger::NOTICE, Chain("Skipping logfile lsn ") + Chain(logRec.getLSN())
+ Chain(" ( expected ") + Chain(_pDBMng->getLSN(tabSetId)) + Chain(")"));
- pitReached = true;
rstate = CegoRecoveryManager::RECPITREACHED;
@@ -938,9 +885,6 @@
_pDBMng->log(_modId, Logger::NOTICE, Chain("Recovery finished with lsn ") + Chain(lsn));
- if ( lsn == 0 )
- rstate=CegoRecoveryManager::RECINCOMPLETE;
-
return rstate;
}
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoRecoveryManager.h
^
|
@@ -67,7 +67,7 @@
CegoRecoveryManager(CegoDistManager *pTabMng);
~CegoRecoveryManager();
- long recoverTableSet(const Chain& tableSet, int pit, bool waitForSync, bool treatOnlineLog);
+ long recoverTableSet(const Chain& tableSet, int pit, bool waitForSync);
RecoveryState recoverCurrentTransactionLog(int tabSetId, int pit, long& lsn, int& ts);
private:
@@ -204,7 +204,7 @@
ListT<UpdateRecord> _updRecList;
void dataFileRecovery(const Chain& tableSet, int tabSetId, long lsn);
- long transactionRecovery(const Chain& tableSet, int tabSetId, long cplsn, int pit, bool treatOnlineLog);
+ long transactionRecovery(const Chain& tableSet, int tabSetId, long cplsn, int pit);
int recoverCurrentDataFileLog(int tabSetId, bool& endOfBackup);
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoXMLSpace.cc
^
|
@@ -2458,7 +2458,7 @@
}
-void CegoXMLSpace::getActiveTableSet(const Chain& primary, ListT<Chain>& tsList)
+void CegoXMLSpace::getActiveTableSet(const Chain& primary, ListT<Chain>& tsList, bool includeRecovery)
{
P();
Element *pRoot = _pDoc->getRootElement();
@@ -2471,7 +2471,7 @@
if ( (*pTSE)->getAttributeValue(XML_PRIMARY_ATTR) == primary
&& ( (*pTSE)->getAttributeValue(XML_RUNSTATE_ATTR) == Chain(XML_ONLINE_VALUE)
|| (*pTSE)->getAttributeValue(XML_RUNSTATE_ATTR) == Chain(XML_BACKUP_VALUE)
- || (*pTSE)->getAttributeValue(XML_RUNSTATE_ATTR) == Chain(XML_RECOVERY_VALUE) ) )
+ || ( (*pTSE)->getAttributeValue(XML_RUNSTATE_ATTR) == Chain(XML_RECOVERY_VALUE) && includeRecovery )))
{
tsList.Insert((*pTSE)->getAttributeValue(XML_NAME_ATTR));
}
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/src/CegoXMLSpace.h
^
|
@@ -206,7 +206,7 @@
int nextTSID();
void getAllActiveTableSet(ListT<Chain>& tsList);
- void getActiveTableSet(const Chain& primary, ListT<Chain>& tsList);
+ void getActiveTableSet(const Chain& primary, ListT<Chain>& tsList, bool includeRecovery = true);
Chain getTableSetRunState(const Chain& tableSet);
void setTableSetRunState(const Chain& tableSet, const Chain& status);
|
[-]
[+]
|
Changed |
cego-2.15.3.tar.bz2/tools/cgrecover
^
|
@@ -24,14 +24,22 @@
### end of customizing ####
-echo "Stopping tableset $TS .."
+RUNSTATE=`$CGADM --server=$HOST --port=$PORT --user=$USER --cmd="show tableset ${TS}" --raw | grep RunState | awk '{ print $2 }'`
-# $CGADM --server=$HOST --port=$PORT --user=$USER --cmd="stop tableset ${TS};"
-# if [ $? -ne 0 ]
-# then
-# echo "Cannot stop tableset $TS"
-# exit 1
-# fi
+echo "Runstate is $RUNSTATE"
+
+if [ "$RUNSTATE" = "ONLINE" ]
+then
+
+ echo "Stopping tableset $TS .."
+
+ $CGADM --server=$HOST --port=$PORT --user=$USER --cmd="stop tableset ${TS};"
+ if [ $? -ne 0 ]
+ then
+ echo "Cannot stop tableset $TS"
+ exit 1
+ fi
+fi
echo "Restoring datafiles .."
tar -xvf $BUFILE
|