From 6cb9a206b8e919c6d681f896d6c2e959ec0cd18e Mon Sep 17 00:00:00 2001 From: ahodgkinson Date: Thu, 20 Jul 2006 20:16:52 +0000 Subject: [PATCH] FLAIM Change. Enhancements to reduce the overhead of growing and shrinking roll-forward and roll-back log files. git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@688 0109f412-320b-0410-ab79-c3e0c5ffbbe6 --- flaim/src/fdbcnfig.cpp | 87 +++++++++++++++++-------- flaim/src/filesys.h | 2 +- flaim/src/flaim.h | 14 +++- flaim/src/flopen.cpp | 3 + flaim/src/flreduce.cpp | 15 ++++- flaim/src/fstructs.h | 5 ++ flaim/src/scache.cpp | 142 ++++++++++++++++++----------------------- 7 files changed, 157 insertions(+), 111 deletions(-) diff --git a/flaim/src/fdbcnfig.cpp b/flaim/src/fdbcnfig.cpp index eff394a..f0be638 100644 --- a/flaim/src/fdbcnfig.cpp +++ b/flaim/src/fdbcnfig.cpp @@ -25,10 +25,10 @@ #include "flaimsys.h" FSTATIC RCODE flmDbGetSizes( - FDB * pDb, - FLMUINT64 * pui64DbFileSize, - FLMUINT64 * pui64RollbackFileSize, - FLMUINT64 * pui64RflFileSize); + FDB * pDb, + FLMUINT64 * pui64DbFileSize, + FLMUINT64 * pui64RollbackFileSize, + FLMUINT64 * pui64RflFileSize); void flmGetCPInfo( void * pFilePtr, @@ -50,9 +50,9 @@ FLMEXP void FLMAPI FlmSetIndexingCallback( Desc: Returns indexing callback function *******************************************************************************/ FLMEXP void FLMAPI FlmGetIndexingCallback( - HFDB hDb, - IX_CALLBACK * pfnIxCallback, - void ** ppvAppData) + HFDB hDb, + IX_CALLBACK * pfnIxCallback, + void ** ppvAppData) { if (pfnIxCallback) { @@ -90,8 +90,8 @@ Desc : Returns to the user the sessions current Rec Validator Hook values. *******************************************************************************/ FLMEXP void FLMAPI FlmGetRecValidatorHook( HFDB hDb, - REC_VALIDATOR_HOOK * pfnRecValidatorHook, // [out] RecValidator func pointer - void ** ppvAppData) // [out] application data + REC_VALIDATOR_HOOK * pfnRecValidatorHook, + void ** ppvAppData) { if (pfnRecValidatorHook) { @@ -109,9 +109,9 @@ Desc : Configures a callback function which is called to return general purpose information. *******************************************************************************/ FLMEXP void FLMAPI FlmSetStatusHook( - HFDB hDb, - STATUS_HOOK fnStatusHook, - void * pvAppData) + HFDB hDb, + STATUS_HOOK fnStatusHook, + void * pvAppData) { ((FDB *)hDb)->fnStatus = fnStatusHook; ((FDB *)hDb)->StatusData = pvAppData; @@ -121,9 +121,9 @@ FLMEXP void FLMAPI FlmSetStatusHook( Desc : Returns to the user the session's current status hook values. *******************************************************************************/ FLMEXP void FLMAPI FlmGetStatusHook( - HFDB hDb, - STATUS_HOOK * pfnStatusHook, - void ** ppvAppData) + HFDB hDb, + STATUS_HOOK * pfnStatusHook, + void ** ppvAppData) { if (pfnStatusHook) { @@ -140,18 +140,18 @@ FLMEXP void FLMAPI FlmGetStatusHook( Desc: Allows an application to configure various options for a database. *******************************************************************************/ FLMEXP RCODE FLMAPI FlmDbConfig( - HFDB hDb, - eDbConfigType eConfigType, - void * pvValue1, - void * pvValue2) + HFDB hDb, + eDbConfigType eConfigType, + void * pvValue1, + void * pvValue2) { - RCODE rc = FERR_OK; - FDB * pDb = (FDB *)hDb; - FFILE * pFile = pDb->pFile; - LFILE * pLFile; - FLMBOOL bDbInitialized = FALSE; - FLMBOOL bStartedTrans = FALSE; - FLMBOOL bDbLocked = FALSE; + RCODE rc = FERR_OK; + FDB * pDb = (FDB *)hDb; + FFILE * pFile = pDb->pFile; + LFILE * pLFile; + FLMBOOL bDbInitialized = FALSE; + FLMBOOL bStartedTrans = FALSE; + FLMBOOL bDbLocked = FALSE; // Process the client/server request @@ -231,6 +231,8 @@ FLMEXP RCODE FLMAPI FlmDbConfig( } case FDB_FILE_EXTEND_SIZE: + case FDB_RFL_FOOTPRINT_SIZE: + case FDB_RBL_FOOTPRINT_SIZE: { if( RC_BAD( rc = Wire.sendNumber( WIRE_VALUE_NUMBER1, (FLMUINT)pvValue1))) @@ -652,6 +654,19 @@ Transmission_Error: break; } + case FDB_RFL_FOOTPRINT_SIZE: + { + pFile->uiRflFootprintSize = f_roundUp( (FLMUINT)pvValue1, 512); + break; + } + + case FDB_RBL_FOOTPRINT_SIZE: + { + pFile->uiRblFootprintSize = f_roundUp( (FLMUINT)pvValue1, + pFile->FileHdr.uiBlockSize); + break; + } + case FDB_SET_APP_DATA: { pDb->pvAppData = pvValue1; @@ -1107,7 +1122,8 @@ FLMEXP RCODE FLMAPI FlmDbGetConfig( goto Exit; } - if (RC_BAD( rc = Wire.sendNumber( WIRE_VALUE_TYPE, (FLMUINT)eGetConfigType))) + if (RC_BAD( rc = Wire.sendNumber( WIRE_VALUE_TYPE, + (FLMUINT)eGetConfigType))) { goto Transmission_Error; } @@ -1176,6 +1192,8 @@ FLMEXP RCODE FLMAPI FlmDbGetConfig( case FDB_GET_LAST_BACKUP_TRANS_ID: case FDB_GET_BLOCKS_CHANGED_SINCE_BACKUP: case FDB_GET_FILE_EXTEND_SIZE: + case FDB_GET_RFL_FOOTPRINT_SIZE: + case FDB_GET_RBL_FOOTPRINT_SIZE: case FDB_GET_APP_DATA: case FDB_GET_NEXT_INC_BACKUP_SEQ_NUM: case FDB_GET_DICT_SEQ_NUM: @@ -1211,7 +1229,8 @@ FLMEXP RCODE FLMAPI FlmDbGetConfig( case FDB_GET_CHECKPOINT_INFO: { - rc = fcsExtractCheckpointInfo( Wire.getHTD(), (CHECKPOINT_INFO *)pvValue1); + rc = fcsExtractCheckpointInfo( Wire.getHTD(), + (CHECKPOINT_INFO *)pvValue1); break; } @@ -1568,6 +1587,18 @@ Transmission_Error: break; } + case FDB_GET_RFL_FOOTPRINT_SIZE: + { + *((FLMUINT *)pvValue1) = pDb->pFile->uiRflFootprintSize; + break; + } + + case FDB_GET_RBL_FOOTPRINT_SIZE: + { + *((FLMUINT *)pvValue1) = pDb->pFile->uiRblFootprintSize; + break; + } + case FDB_GET_APP_DATA: { *((void **)pvValue1) = pDb->pvAppData; diff --git a/flaim/src/filesys.h b/flaim/src/filesys.h index 328976d..d5c920b 100644 --- a/flaim/src/filesys.h +++ b/flaim/src/filesys.h @@ -690,7 +690,7 @@ struct UCUR; DB_STATS * pDbStats, F_SuperFileHdl * pSFileHdl, FFILE * pFile, - FLMBOOL bDoTruncate, + FLMBOOL bTruncateRollBackLog, FLMBOOL bForceCheckpoint, FLMINT iForceReason, FLMUINT uiCPFileNum, diff --git a/flaim/src/flaim.h b/flaim/src/flaim.h index a1e2727..c52a9f8 100644 --- a/flaim/src/flaim.h +++ b/flaim/src/flaim.h @@ -1782,6 +1782,8 @@ #define DEFAULT_MAX_UNUSED_TIME 120 #define DEFAULT_BLOCK_CACHE_PERCENTAGE 50 #define DEFAULT_FILE_EXTEND_SIZE (8192 * 1024) + #define DEFAULT_RFL_FOOTPRINT_SIZE (100 * 1024 * 1024) + #define DEFAULT_RBL_FOOTPRINT_SIZE (100 * 1024 * 1024) #define DEFAULT_MAX_STRATIFY_ITERATIONS 10000 #define DEFAULT_MAX_STRATIFY_TIME 10 @@ -2245,10 +2247,14 @@ FDB_SET_RFL_SIZE_THRESHOLD, ///< Sets the RFL size threshold (in K bytes). If registered to receive RFL size events, an event will ///< be reported when the on-disk size of the RFL exceeds this value.\ pvValue1 is a FLMUINT which ///< specifies the threshold value in K bytes. - FDB_SET_RFL_SIZE_EVENT_INTERVALS ///< Sets the criteria for determining how often to report RFL size events once the RFL exceeds the + FDB_SET_RFL_SIZE_EVENT_INTERVALS, ///< Sets the criteria for determining how often to report RFL size events once the RFL exceeds the ///< size threshold.\ pvValue1 is a FLMUINT which specifies the minimum number of seconds between ///< events.\ pvValue2 is a FLMUINT which specifies the minimum increase in K bytes of the RFL ///< between events. + FDB_RFL_FOOTPRINT_SIZE, ///< Set the footprint size of the RFL when files are not being kept.\ pvValue1 is a FLMUINT + ///< which specifies the footprint size (in bytes). + FDB_RBL_FOOTPRINT_SIZE ///< Set the footprint size of the roll-back log.\ pvValue1 is a FLMUINT + ///< which specifies the footprint size (in bytes). } eDbConfigType; /// Options for FlmDbGetConfig(). @@ -2309,8 +2315,12 @@ ///< returns the sequence number. FDB_GET_DICT_SEQ_NUM, ///< Get the dictionary sequence number.\ pvValue1 is a FLMUINT * that returns the sequence number. FDB_GET_FFILE_ID, ///< Get the database's unique ID number.\ pvValue1 is a FLMUINT * that returns the number. - FDB_GET_MUST_CLOSE_RC ///< Get the ::RCODE that caused the "must close" flag to be set on the database.\ pvValue1 is + FDB_GET_MUST_CLOSE_RC, ///< Get the ::RCODE that caused the "must close" flag to be set on the database.\ pvValue1 is ///< an ::RCODE * that returns the ::RCODE. + FDB_GET_RFL_FOOTPRINT_SIZE, ///< Get the RFL footprint size.\ pvValue1 is a FLMUINT * which returns the RFL footprint size.\ NOTE: + ///< This size may be set by calling FlmDbConfig() using the eDbConfigType::FDB_RFL_FOOTPRINT_SIZE option. + FDB_GET_RBL_FOOTPRINT_SIZE ///< Get the roll-back log footprint size.\ pvValue1 is a FLMUINT * which returns the RBL footprint size.\ NOTE: + ///< This size may be set by calling FlmDbConfig() using the eDbConfigType::FDB_RBL_FOOTPRINT_SIZE option. } eDbGetConfigType; /// Create a new database. diff --git a/flaim/src/flopen.cpp b/flaim/src/flopen.cpp index cb8ec52..83bf394 100644 --- a/flaim/src/flopen.cpp +++ b/flaim/src/flopen.cpp @@ -1265,6 +1265,9 @@ RCODE flmAllocFile( pFile->uiFFileId = gv_FlmSysData.uiNextFFileId++; pFile->pCPInfo = NULL; pFile->uiFileExtendSize = DEFAULT_FILE_EXTEND_SIZE; + pFile->uiRflFootprintSize = DEFAULT_RFL_FOOTPRINT_SIZE; + pFile->uiRblFootprintSize = DEFAULT_RBL_FOOTPRINT_SIZE; + pFile->krefPool.poolInit( 8192); // Allocate a buffer for writing the database header diff --git a/flaim/src/flreduce.cpp b/flaim/src/flreduce.cpp index 73f15f8..5e06255 100644 --- a/flaim/src/flreduce.cpp +++ b/flaim/src/flreduce.cpp @@ -329,7 +329,9 @@ Transmission_Error: // Commit the transaction { - FLMBOOL bFlagSet; + FLMBOOL bFlagSet; + FLMUINT uiSaveRflFootprintSize = pDb->pFile->uiRflFootprintSize; + FLMUINT uiSaveRblFootprintSize = pDb->pFile->uiRblFootprintSize; if (pDb->uiFlags & FDB_DO_TRUNCATE) { @@ -340,9 +342,20 @@ Transmission_Error: bFlagSet = FALSE; pDb->uiFlags |= FDB_DO_TRUNCATE; } + + // Set the roll-forward and roll-back log thresholds to + // their minimum sizes + + pDb->pFile->uiRflFootprintSize = 512; + pDb->pFile->uiRblFootprintSize = pDb->pFile->FileHdr.uiBlockSize; rc = flmCommitDbTrans( pDb, uiLogicalEOF, TRUE); + // Restore the RFL and RBL footprint sizes + + pDb->pFile->uiRflFootprintSize = uiSaveRflFootprintSize; + pDb->pFile->uiRblFootprintSize = uiSaveRblFootprintSize; + if (!bFlagSet) { pDb->uiFlags &= (~(FDB_DO_TRUNCATE)); diff --git a/flaim/src/fstructs.h b/flaim/src/fstructs.h index c06e698..448250b 100644 --- a/flaim/src/fstructs.h +++ b/flaim/src/fstructs.h @@ -1448,6 +1448,11 @@ typedef struct FFILE // header information for the file. FLMUINT uiMaxFileSize; // Maximum file size. FLMUINT uiFileExtendSize; // Bytes to extend files by. + FLMUINT uiRflFootprintSize; // When RFL files are not being kept, + // this is the desired footprint of + // the RFL on disk + FLMUINT uiRblFootprintSize; // This is the desired footprint of + // the RBL on disk FLMUINT uiUpdateTransID; // This is the transaction ID currently // being used by an active update // transaction on this file. When diff --git a/flaim/src/scache.cpp b/flaim/src/scache.cpp index d900563..d5ab6b9 100644 --- a/flaim/src/scache.cpp +++ b/flaim/src/scache.cpp @@ -176,7 +176,7 @@ FSTATIC RCODE scaFinishCheckpoint( DB_STATS * pDbStats, F_SuperFileHdl * pSFileHdl, FFILE * pFile, - FLMBOOL bDoTruncate, + FLMBOOL bTruncateRollBackLog, FLMUINT uiCPFileNum, FLMUINT uiCPOffset, FLMUINT uiCPStartTime, @@ -7604,7 +7604,7 @@ FSTATIC RCODE scaFinishCheckpoint( DB_STATS * pDbStats, F_SuperFileHdl * pSFileHdl, FFILE * pFile, - FLMBOOL bDoTruncate, + FLMBOOL bTruncateRollBackLog, FLMUINT uiCPFileNum, FLMUINT uiCPOffset, FLMUINT uiCPStartTime, @@ -7619,7 +7619,7 @@ FSTATIC RCODE scaFinishCheckpoint( FLMUINT uiSaveCPFileNum; FLMBOOL bTruncateLog = FALSE; FLMBOOL bTruncateRflFile = FALSE; - FLMUINT uiTruncateRflSize = 0; + FLMUINT uiRflTruncateSize = 0; FLMUINT uiLogEof; FLMUINT uiHighLogFileNumber; #ifdef FLM_DBG_LOG @@ -7666,7 +7666,7 @@ FSTATIC RCODE scaFinishCheckpoint( uiLogEof = (FLMUINT)FB2UD( &pucCommittedLogHdr [LOG_ROLLBACK_EOF]); uiHighLogFileNumber = FSGetFileNumber( uiLogEof); - if (uiHighLogFileNumber > 0 || bDoTruncate || + if( uiHighLogFileNumber > 0 || bTruncateRollBackLog || FSGetFileOffset( uiLogEof) > LOW_VERY_LARGE_LOG_THRESHOLD_SIZE) { CP_INFO * pCPInfo = pFile->pCPInfo; @@ -7677,7 +7677,7 @@ FSTATIC RCODE scaFinishCheckpoint( FLMUINT uiFirstDbInactiveSecs; FLMUINT uiElapTime; FLMUINT uiLastMsgTime = FLM_GET_TIMER(); - FLMBOOL bMustTruncate = (bDoTruncate || + FLMBOOL bMustTruncate = (bTruncateRollBackLog || uiHighLogFileNumber || FSGetFileOffset( uiLogEof) >= HIGH_VERY_LARGE_LOG_THRESHOLD_SIZE) @@ -7748,7 +7748,7 @@ FSTATIC RCODE scaFinishCheckpoint( pFirstDb->pPrevReadTrans = NULL; - if ((pFirstDb->pNextReadTrans = pFile->pFirstKilledTrans) != NULL) + if( (pFirstDb->pNextReadTrans = pFile->pFirstKilledTrans) != NULL) { pFirstDb->pNextReadTrans->pPrevReadTrans = pFirstDb; } @@ -7761,10 +7761,7 @@ FSTATIC RCODE scaFinishCheckpoint( uiElapTime = FLM_ELAPSED_TIME( uiTime, uiFirstDbInactiveTime); uiFirstDbInactiveSecs = FLM_TIMER_UNITS_TO_SECS( uiElapTime); - flmLogMessage( - F_DEBUG_MESSAGE, - FLM_YELLOW, - FLM_BLACK, + flmLogMessage( F_DEBUG_MESSAGE, FLM_YELLOW, FLM_BLACK, "Killed transaction 0x%08X." " Thread: 0x%08X." " Inactive time: %u seconds.", @@ -7778,7 +7775,7 @@ FSTATIC RCODE scaFinishCheckpoint( } else if( !bMustTruncate) { - if (iWaitCnt >= 200) + if( iWaitCnt >= 200) { break; } @@ -7801,10 +7798,7 @@ FSTATIC RCODE scaFinishCheckpoint( uiElapTime = FLM_ELAPSED_TIME( uiTime, uiFirstDbInactiveTime); uiFirstDbInactiveSecs = FLM_TIMER_UNITS_TO_SECS( uiElapTime); - flmLogMessage( - F_DEBUG_MESSAGE, - FLM_YELLOW, - FLM_BLACK, + flmLogMessage( F_DEBUG_MESSAGE, FLM_YELLOW, FLM_BLACK, "Waiting for transaction 0x%08X to complete." " Thread: 0x%08X." " Inactive time: %u seconds.", @@ -7817,6 +7811,7 @@ FSTATIC RCODE scaFinishCheckpoint( f_sleep( 100); } + f_mutexLock( gv_FlmSysData.hShareMutex); pFirstDb = pFile->pFirstReadTrans; } @@ -7827,30 +7822,32 @@ FSTATIC RCODE scaFinishCheckpoint( } } - if ((!pFile->pFirstReadTrans) || - (pFile->pFirstReadTrans->LogHdr.uiCurrTransID >= - uiCurrTransID)) + if( !pFile->pFirstReadTrans || + pFile->pFirstReadTrans->LogHdr.uiCurrTransID >= uiCurrTransID) { // We may want to truncate the log file if it has grown really big. - if ((uiHighLogFileNumber > 0) || - (FSGetFileOffset( uiLogEof) > pFile->uiFileExtendSize)) + if( uiHighLogFileNumber > 0 || + FSGetFileOffset( uiLogEof) > pFile->uiRblFootprintSize) { bTruncateLog = TRUE; } + UD2FBA( (FLMUINT32)pFile->FileHdr.uiBlockSize, - &pucCommittedLogHdr [LOG_ROLLBACK_EOF]); + &pucCommittedLogHdr[ LOG_ROLLBACK_EOF]); #ifdef FLM_DBG_LOG bResetRBL = TRUE; #endif } - UD2FBA( 0, &pucCommittedLogHdr [LOG_PL_FIRST_CP_BLOCK_ADDR]); + + UD2FBA( 0, &pucCommittedLogHdr[ LOG_PL_FIRST_CP_BLOCK_ADDR]); // Set the checkpoint RFL file number and offset to be the same as // the last transaction's RFL file number and offset if nothing // is passed in. If a non-zero uiCPFileNum is passed in, it is because // we are checkpointing the last transaction that has been recovered // by the recovery process. + // // In this case, instead of moving the pointers all the way forward, // to the last committed transaction, we simply move them forward to // the last recovered transaction. @@ -7880,12 +7877,11 @@ FSTATIC RCODE scaFinishCheckpoint( f_memcpy( &pucCommittedLogHdr [LOG_RFL_LAST_CP_FILE_NUM], &pucCommittedLogHdr [LOG_RFL_FILE_NUM], 4); - if (!pucCommittedLogHdr [LOG_KEEP_RFL_FILES]) + if( !pucCommittedLogHdr [LOG_KEEP_RFL_FILES]) { UD2FBA( 512, &pucCommittedLogHdr [LOG_RFL_LAST_CP_OFFSET]); - if (bResetRflFile) + if( bResetRflFile) { - // This will cause the RFL file to be recreated on the // next transaction - causing the keep signature to be // changed. Also need to set up to use new serial @@ -7898,37 +7894,20 @@ FSTATIC RCODE scaFinishCheckpoint( f_createSerialNumber( &pucCommittedLogHdr [LOG_RFL_NEXT_SERIAL_NUM]); } - - // If LOG_RFL_LAST_TRANS_OFFSET is zero, someone has set this up - // intentionally to cause the RFL file to be created at the - // beginning of the next transaction. We don't want to lose - // that, so if it is zero, we don't change it. - else if (FB2UD( &pucCommittedLogHdr[ LOG_RFL_LAST_TRANS_OFFSET]) != 0) { + // If LOG_RFL_LAST_TRANS_OFFSET is zero, someone has set this up + // intentionally to cause the RFL file to be created at the + // beginning of the next transaction. We don't want to lose + // that, so if it is zero, we don't change it. + UD2FBA( 512, &pucCommittedLogHdr[ LOG_RFL_LAST_TRANS_OFFSET]); } - uiTruncateRflSize = - (FLMUINT)FB2UD( &pucCommittedLogHdr[ LOG_RFL_MIN_FILE_SIZE]); - - if( (uiSaveTransOffset >= (pFile->uiFileExtendSize * 2)) || - (uiSaveTransOffset >= uiTruncateRflSize)) + if( uiSaveTransOffset >= pFile->uiRflFootprintSize) { bTruncateRflFile = TRUE; - - if( uiTruncateRflSize > (pFile->uiFileExtendSize * 2)) - { - uiTruncateRflSize = pFile->uiFileExtendSize; - } - else if( uiTruncateRflSize < 512) - { - uiTruncateRflSize = 512; - } - - // Set to nearest 512 byte boundary - - uiTruncateRflSize &= 0xFFFFFE00; + uiRflTruncateSize = pFile->uiRflFootprintSize; } } else @@ -7958,7 +7937,7 @@ FSTATIC RCODE scaFinishCheckpoint( // for the transaction offset to still be zero at this point if // we haven't done a non-empty transaction yet. - if (!uiLastTransOffset) + if( !uiLastTransOffset) { uiLastTransOffset = 512; } @@ -7979,7 +7958,7 @@ FSTATIC RCODE scaFinishCheckpoint( // Write the log header - this will complete the checkpoint. - if (RC_BAD( rc = flmWriteLogHdr( pDbStats, pSFileHdl, pFile, + if( RC_BAD( rc = flmWriteLogHdr( pDbStats, pSFileHdl, pFile, pucCommittedLogHdr, pFile->ucCheckpointLogHdr, TRUE))) { @@ -7991,17 +7970,24 @@ FSTATIC RCODE scaFinishCheckpoint( f_mutexUnlock( gv_FlmSysData.hShareMutex); goto Exit; } - else if (bTruncateLog) + else if( bTruncateLog) { - if (uiHighLogFileNumber) + FLMUINT uiRblFootprintSize = pFile->uiRblFootprintSize; + + if( uiHighLogFileNumber) { - (void)pSFileHdl->truncateFiles( - FIRST_LOG_BLOCK_FILE_NUMBER( - pFile->FileHdr.uiVersionNum), - uiHighLogFileNumber); + (void)pSFileHdl->truncateFiles( + FIRST_LOG_BLOCK_FILE_NUMBER( pFile->FileHdr.uiVersionNum), + uiHighLogFileNumber); } - (void)pSFileHdl->truncateFile( 0, pFile->uiFileExtendSize); + if( uiRblFootprintSize < pFile->FileHdr.uiBlockSize) + { + flmAssert( 0); + uiRblFootprintSize = pFile->FileHdr.uiBlockSize; + } + + (void)pSFileHdl->truncateFile( 0, uiRblFootprintSize); } #ifdef FLM_DBG_LOG @@ -8021,6 +8007,7 @@ FSTATIC RCODE scaFinishCheckpoint( (unsigned)pFile->uiFFileId, (unsigned)FB2UD( &pucCommittedLogHdr [LOG_LAST_CP_TRANS_ID])); } + flmDbgLogMsg( szMsg); } #endif @@ -8040,30 +8027,29 @@ FSTATIC RCODE scaFinishCheckpoint( uiNewCPFileNum = (FLMUINT)FB2UD( &pucCommittedLogHdr [LOG_RFL_LAST_CP_FILE_NUM]); - if (!pucCommittedLogHdr [LOG_KEEP_RFL_FILES] && - uiSaveCPFileNum != uiNewCPFileNum && - uiNewCPFileNum > 1) + if( !pucCommittedLogHdr [LOG_KEEP_RFL_FILES] && + uiSaveCPFileNum != uiNewCPFileNum && uiNewCPFileNum > 1) { FLMUINT uiLastRflFileDeleted = (FLMUINT)FB2UD( &pucCommittedLogHdr [LOG_LAST_RFL_FILE_DELETED]); uiLastRflFileDeleted++; - while (uiLastRflFileDeleted < uiNewCPFileNum) + + while( uiLastRflFileDeleted < uiNewCPFileNum) { char szLogFilePath [F_PATH_MAX_SIZE]; RCODE TempRc; - if (RC_BAD( pFile->pRfl->getFullRflFileName( - uiLastRflFileDeleted, - szLogFilePath))) + if( RC_BAD( pFile->pRfl->getFullRflFileName( + uiLastRflFileDeleted, szLogFilePath))) { break; } - if (RC_BAD( TempRc = gv_FlmSysData.pFileSystem->deleteFile( + if( RC_BAD( TempRc = gv_FlmSysData.pFileSystem->deleteFile( szLogFilePath))) { - if (TempRc != FERR_IO_PATH_NOT_FOUND && + if( TempRc != FERR_IO_PATH_NOT_FOUND && TempRc != FERR_IO_INVALID_PATH) { break; @@ -8075,15 +8061,14 @@ FSTATIC RCODE scaFinishCheckpoint( // If we actually deleted a file, update the log header. - if (uiLastRflFileDeleted != + if( uiLastRflFileDeleted != (FLMUINT)FB2UD( &pucCommittedLogHdr [LOG_LAST_RFL_FILE_DELETED])) { UD2FBA( (FLMUINT32)uiLastRflFileDeleted, &pucCommittedLogHdr [LOG_LAST_RFL_FILE_DELETED]); - if (RC_BAD( rc = flmWriteLogHdr( pDbStats, pSFileHdl, pFile, - pucCommittedLogHdr, - pFile->ucCheckpointLogHdr, TRUE))) + if( RC_BAD( rc = flmWriteLogHdr( pDbStats, pSFileHdl, pFile, + pucCommittedLogHdr, pFile->ucCheckpointLogHdr, TRUE))) { goto Exit; } @@ -8100,13 +8085,13 @@ FSTATIC RCODE scaFinishCheckpoint( if( bTruncateRflFile) { - (void)pFile->pRfl->truncate( uiTruncateRflSize); + (void)pFile->pRfl->truncate( uiRflTruncateSize); } // Truncate the files, if requested to do so - this would be a request of // FlmDbReduceSize. - if( bDoTruncate) + if( bTruncateRollBackLog) { if( RC_BAD( rc = pSFileHdl->truncateFile( (FLMUINT)FB2UD( &pucCommittedLogHdr [LOG_LOGICAL_EOF])))) @@ -8163,6 +8148,7 @@ FSTATIC RCODE scaFinishCheckpoint( uiMaximum = (FLMUINT)(((FLMUINT64)uiTotalToWrite * (FLMUINT64)ui15Seconds) / (FLMUINT64)uiCPElapsedTime); + if( uiMaximum) { // Low is maximum minus what could be written in roughly @@ -8206,7 +8192,7 @@ RCODE ScaDoCheckpoint( DB_STATS * pDbStats, F_SuperFileHdl * pSFileHdl, FFILE * pFile, - FLMBOOL bDoTruncate, + FLMBOOL bTruncateRollBackLog, FLMBOOL bForceCheckpoint, FLMINT iForceReason, FLMUINT uiCPFileNum, @@ -8270,9 +8256,8 @@ RCODE ScaDoCheckpoint( // Write out log blocks first. bWroteAll = TRUE; - if (RC_BAD( rc = ScaFlushLogBlocks( pDbStats, pSFileHdl, pFile, - TRUE, uiMaxDirtyCache, - &bForceCheckpoint, &bWroteAll))) + if( RC_BAD( rc = ScaFlushLogBlocks( pDbStats, pSFileHdl, pFile, + TRUE, uiMaxDirtyCache, &bForceCheckpoint, &bWroteAll))) { goto Exit; } @@ -8305,7 +8290,7 @@ RCODE ScaDoCheckpoint( // need to finish the checkpoint. if( RC_BAD( rc = scaFinishCheckpoint( pDbStats, pSFileHdl, pFile, - bDoTruncate, uiCPFileNum, uiCPOffset, uiCPStartTime, uiTotalToWrite))) + bTruncateRollBackLog, uiCPFileNum, uiCPOffset, uiCPStartTime, uiTotalToWrite))) { goto Exit; } @@ -8699,7 +8684,6 @@ RCODE ScaDecryptBlock( goto Exit; } - #ifndef FLM_USE_NICI rc = RC_SET( FERR_ENCRYPTION_UNAVAILABLE); goto Exit;