#include <Database.h>
Inheritance diagram for Database:
Public Member Functions | |
virtual | ~Database () |
const ConfigMap & | getConfigMap () const |
SharedCache | getCache () const |
SharedSegmentFactory | getSegmentFactory () const |
SharedSegment | getDataSegment () const |
SharedSegment | getTempSegment () const |
SharedCheckpointThread | getCheckpointThread () const |
virtual SharedSegment | getSegmentById (SegmentId segmentId, SharedSegment pDataSegment) |
Finds a segment by its SegmentId. | |
virtual void | writeStats (StatsTarget &target) |
Writes a current stats snapshot to a StatsTarget. | |
SharedLogicalTxnLog | getTxnLog () const |
StoredTypeDescriptorFactory const & | getTypeFactory () const |
bool | isRecoveryRequired () const |
bool | shouldForceTxns () const |
bool | areSnapshotsEnabled () const |
void | recoverOnline () |
void | recover (LogicalTxnParticipantFactory &txnParticipantFactory) |
void | checkpointImpl (CheckpointType=CHECKPOINT_FLUSH_ALL) |
void | requestCheckpoint (CheckpointType checkpointType, bool async) |
Receives request for a checkpoint. | |
void | deallocateOldPages (TxnId oldestLabelCsn) |
Deallocates old snapshot pages that are no longer referenced by any active transactions, as well as active labels marking snapshots in time. | |
void | setLastCommittedTxnId (TxnId txnId) |
Saves the id of the last committed transaction. | |
TxnId | getLastCommittedTxnId () |
| |
TxnId | initiateBackup (const std::string &backupFilePathname, bool checkSpaceRequirements, FileSize spacePadding, TxnId lowerBoundCsn, const std::string &compressionProgram, FileSize &dataDeviceSize, const volatile bool &aborted) |
Initiates a backup of the data segment. | |
void | completeBackup (TxnId lowerBoundCsn, TxnId upperBoundCsn, const volatile bool &aborted) |
Completes the remainder of a backup by backing up the data pages that have allocationCsn's in between two specified bounds. | |
void | abortBackup () |
Aborts a backup that may or may not have been previously initiated. | |
void | restoreFromBackup (const std::string &backupFilePathname, FileSize newSize, const std::string &compressionProgram, TxnId lowerBoundCsn, TxnId upperBoundCsn, const volatile bool &aborted) |
Restores the data segment from a backup file. | |
bool | isClosed () const |
| |
void | close () |
Closes this object, releasing any unallocated resources. | |
virtual void | initTraceSource (SharedTraceTarget pTraceTarget, std::string name) |
For use when initialization has to be deferred until after construction. | |
void | trace (TraceLevel level, std::string message) const |
Records a trace message. | |
bool | isTracing () const |
| |
bool | isTracingLevel (TraceLevel level) const |
Determines whether a particular level is being traced. | |
TraceTarget & | getTraceTarget () const |
| |
SharedTraceTarget | getSharedTraceTarget () const |
| |
std::string | getTraceSourceName () const |
Gets the name of this source. | |
void | setTraceSourceName (std::string const &n) |
Sets the name of this source. | |
TraceLevel | getMinimumTraceLevel () const |
void | disableTracing () |
Static Public Member Functions | |
static SharedDatabase | newDatabase (SharedCache pCache, ConfigMap const &configMap, DeviceMode openMode, SharedTraceTarget pTraceTarget, SharedPseudoUuidGenerator pUuidGenerator=SharedPseudoUuidGenerator()) |
Static Public Attributes | |
static ParamName | paramDatabaseDir |
static ParamName | paramResourceDir |
static ParamName | paramForceTxns |
static ParamName | paramDisableSnapshots |
static ParamName | paramDatabasePrefix |
static ParamName | paramTempPrefix |
static ParamName | paramShadowLogPrefix |
static ParamName | paramTxnLogPrefix |
static ParamName | paramInitSizeSuffix |
static ParamName | paramMaxSizeSuffix |
static ParamName | paramIncSizeSuffix |
static ParamVal | valLogAllocLinear |
static ParamVal | valLogAllocCircular |
static const SegmentId | DEFAULT_DATA_SEGMENT_ID |
static const SegmentId | TEMP_SEGMENT_ID |
Protected Attributes | |
bool | needsClose |
StrictMutex | mutex |
LocalCondition | condition |
Private Member Functions | |
Database (SharedCache pCache, ConfigMap const &configMap, DeviceMode openMode, SharedTraceTarget pTraceTarget, SharedPseudoUuidGenerator pUuidGenerator) | |
virtual void | closeImpl () |
Must be implemented by derived class to release any resources. | |
void | init () |
void | createTxnLog (DeviceMode) |
SharedSegment | createTxnLogSegment (DeviceMode, PageId) |
SharedSegment | createShadowLog (DeviceMode) |
void | createDataDevice (LinearDeviceSegmentParams &) |
void | createDataSegment (SharedSegment, LinearDeviceSegmentParams &) |
void | createTempSegment () |
void | allocateHeader () |
void | writeHeader () |
void | loadHeader (bool) |
void | closeDevices () |
void | deleteLogs () |
void | openSegments () |
void | prepareForRecovery () |
void | recoverPhysical (CheckpointType) |
void | readDeviceParams (std::string paramNamePrefix, DeviceMode deviceMode, LinearDeviceSegmentParams &deviceParams) |
void | cleanupBackupRestore (bool isBackup) |
Private Attributes | |
DeviceId | dataDeviceId |
SharedRandomAccessDevice | pDataDevice |
DeviceId | tempDeviceId |
DeviceId | shadowDeviceId |
DeviceId | txnLogDeviceId |
std::string | dataDeviceName |
std::string | tempDeviceName |
std::string | shadowDeviceName |
std::string | txnLogDeviceName |
SharedCache | pCache |
SharedSegmentFactory | pSegmentFactory |
SharedSegment | pHeaderSegment |
SharedSegment | pDataSegment |
SharedSegment | pTempSegment |
VersionedSegment * | pVersionedSegment |
SharedLogicalTxnLog | pTxnLog |
PageId | headerPageId1 |
PageId | headerPageId2 |
DatabaseHeader | header |
LogicalTxnParticipantFactory * | pTxnParticipantFactory |
bool | forceTxns |
bool | disableSnapshots |
bool | recoveryRequired |
DeviceMode | openMode |
ConfigMap | configMap |
StandardTypeDescriptorFactory | typeFactory |
SharedCheckpointThread | pCheckpointThread |
SharedPseudoUuidGenerator | pUuidGenerator |
uint | nCheckpointsStat |
Cumulative counter cleared whenever writeStats is called. | |
uint | nCheckpoints |
Cumulative counter. | |
bool | disableDeallocateOld |
If true, ALTER SYSTEM DEALLOCATE OLD is a no-op. | |
SharedSegPageBackupRestoreDevice | pBackupRestoreDevice |
Device used to read and write the backup file during backup and restore. | |
SegmentAccessor | scratchAccessor |
Scratch accessor used during backup and restore. |
Definition at line 49 of file Database.h.
Database::Database | ( | SharedCache | pCache, | |
ConfigMap const & | configMap, | |||
DeviceMode | openMode, | |||
SharedTraceTarget | pTraceTarget, | |||
SharedPseudoUuidGenerator | pUuidGenerator | |||
) | [explicit, private] |
Definition at line 96 of file Database.cpp.
References disableDeallocateOld, and openMode.
Referenced by newDatabase().
00102 : TraceSource(pTraceTarget,"database"), 00103 pCache(pCacheInit), 00104 configMap(configMapInit), 00105 pUuidGenerator(pUuidGeneratorInit) 00106 { 00107 openMode = openModeInit; 00108 disableDeallocateOld = false; 00109 }
Database::~Database | ( | ) | [virtual] |
void Database::closeImpl | ( | ) | [private, virtual] |
Must be implemented by derived class to release any resources.
Implements ClosableObject.
Definition at line 246 of file Database.cpp.
References areSnapshotsEnabled(), checkpointImpl(), closeDevices(), deleteLogs(), VersionedRandomAllocationSegment::freeTempPages(), header, isRecoveryRequired(), pCheckpointThread, pDataSegment, pTempSegment, pTxnLog, TRACE_INFO, and DatabaseHeader::versionNumber.
00247 { 00248 FENNEL_TRACE( 00249 TRACE_INFO, 00250 "closing database"); 00251 if (pCheckpointThread) { 00252 pCheckpointThread->close(); 00253 } 00254 00255 // Free any leftover temp pages used for page versioning 00256 if (pDataSegment && areSnapshotsEnabled()) { 00257 VersionedRandomAllocationSegment *pVersionedRandomSegment = 00258 SegmentFactory::dynamicCast<VersionedRandomAllocationSegment *>( 00259 pDataSegment); 00260 pVersionedRandomSegment->freeTempPages(); 00261 } 00262 00263 // Verify that no garbage temp pages remain allocated. 00264 if (pTempSegment) { 00265 assert(pTempSegment->getAllocatedSizeInPages() == 0); 00266 } 00267 00268 if (isRecoveryRequired()) { 00269 closeDevices(); 00270 } else { 00271 // NOTE jvs 14-Nov-2006: In case we're auto-closing after 00272 // a failed startup, skip checkpoint if we don't have 00273 // everything we need for it. 00274 if (pTxnLog && pDataSegment) { 00275 checkpointImpl(); 00276 } 00277 closeDevices(); 00278 deleteLogs(); 00279 } 00280 FENNEL_TRACE( 00281 TRACE_INFO, 00282 "database closed; page version = " 00283 << header.versionNumber); 00284 }
void Database::init | ( | ) | [private] |
Definition at line 111 of file Database.cpp.
References configMap, DeviceMode::create, dataDeviceId, dataDeviceName, disableSnapshots, FileSystem::doesFileExist(), forceTxns, ConfigMap::getBoolParam(), Segment::getLinearPageId(), TraceSource::getSharedTraceTarget(), ConfigMap::getStringParam(), header, headerPageId1, headerPageId2, DatabaseHeader::MAGIC_NUMBER, StoredNode::magicNumber, nCheckpoints, nCheckpointsStat, SegmentFactory::newSegmentFactory(), openMode, openSegments(), paramDatabaseDir, paramDisableSnapshots, paramForceTxns, paramResourceDir, prepareForRecovery(), pSegmentFactory, recoveryRequired, shadowDeviceId, shadowDeviceName, tempDeviceId, tempDeviceName, txnLogDeviceId, txnLogDeviceName, and DatabaseHeader::versionNumber.
00112 { 00113 forceTxns = configMap.getBoolParam(paramForceTxns); 00114 disableSnapshots = configMap.getBoolParam(paramDisableSnapshots); 00115 00116 // NOTE: do this early in case other initialization throws exceptions 00117 // (and to prevent thread-safety issues later on) 00118 std::string resourceDir = configMap.getStringParam(paramResourceDir); 00119 if (resourceDir == "") { 00120 // If we weren't told explicitly where to find resources, make sure 00121 // we can rely on an environment variable setting. TODO: 00122 // instead of pre-checking this, get information back from 00123 // FennelResource to tell us whether it was successfully initialized. 00124 assert(getenv("FENNEL_HOME")); 00125 } else { 00126 FennelResource::setResourceFileLocation(resourceDir); 00127 } 00128 FennelResource::instance(); 00129 00130 dataDeviceId = DeviceId(1); 00131 shadowDeviceId = DeviceId(2); 00132 txnLogDeviceId = DeviceId(3); 00133 tempDeviceId = DeviceId(4); 00134 00135 headerPageId1 = Segment::getLinearPageId(0); 00136 headerPageId2 = Segment::getLinearPageId(1); 00137 00138 header.versionNumber = SegVersionNum(0); 00139 recoveryRequired = false; 00140 00141 // REVIEW: Have to do this so that later assignments from header to stored 00142 // data work correctly. But it breaks encapsulation. Find a better way. 00143 header.magicNumber = DatabaseHeader::MAGIC_NUMBER; 00144 00145 // TODO: use boost filesystem library for platform-independent path 00146 // manipulation 00147 std::string databaseDir = configMap.getStringParam(paramDatabaseDir); 00148 // TODO: real excn 00149 assert(databaseDir != ""); 00150 00151 dataDeviceName = databaseDir + "/db.dat"; 00152 shadowDeviceName = databaseDir + "/shadowlog.dat"; 00153 txnLogDeviceName = databaseDir + "/txnlog.dat"; 00154 tempDeviceName = databaseDir + "/temp.dat"; 00155 00156 nCheckpoints = nCheckpointsStat = 0; 00157 00158 pSegmentFactory = SegmentFactory::newSegmentFactory( 00159 configMap,getSharedTraceTarget()); 00160 00161 if (!openMode.create) { 00162 // TODO: real excn 00163 assert(FileSystem::doesFileExist(dataDeviceName.c_str())); 00164 if (FileSystem::doesFileExist(shadowDeviceName.c_str())) { 00165 prepareForRecovery(); 00166 return; 00167 } 00168 } 00169 00170 openSegments(); 00171 }
void Database::createTxnLog | ( | DeviceMode | ) | [private] |
Definition at line 382 of file Database.cpp.
References createTxnLogSegment(), header, LogicalTxnLog::newLogicalTxnLog(), NULL_PAGE_ID, DatabaseHeader::onlineUuid, pCache, pSegmentFactory, pTxnLog, and DatabaseHeader::txnLogCheckpointMemento.
Referenced by openSegments().
00383 { 00384 SharedSegment pTxnLogSegment = createTxnLogSegment( 00385 txnLogMode,NULL_PAGE_ID); 00386 SegmentAccessor segmentAccessor(pTxnLogSegment,pCache); 00387 pTxnLog = LogicalTxnLog::newLogicalTxnLog( 00388 segmentAccessor, 00389 header.onlineUuid, 00390 pSegmentFactory); 00391 pTxnLog->checkpoint(header.txnLogCheckpointMemento); 00392 }
SharedSegment Database::createTxnLogSegment | ( | DeviceMode | , | |
PageId | ||||
) | [private] |
Definition at line 347 of file Database.cpp.
References LinearDeviceSegmentParams::firstBlockId, forceTxns, MAXU, LinearDeviceSegmentParams::nPagesAllocated, LinearDeviceSegmentParams::nPagesIncrement, LinearDeviceSegmentParams::nPagesMax, LinearDeviceSegmentParams::nPagesMin, paramTxnLogPrefix, pCache, pCheckpointThread, pSegmentFactory, readDeviceParams(), CompoundId::setBlockNum(), CompoundId::setDeviceId(), txnLogDeviceId, and txnLogDeviceName.
Referenced by createTxnLog(), and recover().
00349 { 00350 SharedRandomAccessDevice pTxnLogDevice( 00351 new RandomAccessFileDevice(txnLogDeviceName,txnLogMode)); 00352 pCache->registerDevice(txnLogDeviceId,pTxnLogDevice); 00353 00354 LinearDeviceSegmentParams deviceParams; 00355 readDeviceParams(paramTxnLogPrefix,txnLogMode,deviceParams); 00356 CompoundId::setDeviceId(deviceParams.firstBlockId,txnLogDeviceId); 00357 CompoundId::setBlockNum(deviceParams.firstBlockId,0); 00358 if (forceTxns) { 00359 deviceParams.nPagesAllocated = 0; 00360 } else { 00361 deviceParams.nPagesAllocated = MAXU; 00362 deviceParams.nPagesIncrement = 0; 00363 deviceParams.nPagesMax = deviceParams.nPagesMin; 00364 } 00365 00366 SharedSegment pLinearSegment = 00367 pSegmentFactory->newLinearDeviceSegment( 00368 pCache, 00369 deviceParams); 00370 00371 SharedSegment pTxnLogSegment; 00372 if (forceTxns) { 00373 pTxnLogSegment = pLinearSegment; 00374 } else { 00375 pTxnLogSegment = pSegmentFactory->newCircularSegment( 00376 pLinearSegment,pCheckpointThread,oldestPageId); 00377 } 00378 00379 return pTxnLogSegment; 00380 }
SharedSegment Database::createShadowLog | ( | DeviceMode | ) | [private] |
Definition at line 394 of file Database.cpp.
References DeviceMode::create, LinearDeviceSegmentParams::firstBlockId, forceTxns, header, MAXU, LinearDeviceSegmentParams::nPagesAllocated, LinearDeviceSegmentParams::nPagesIncrement, LinearDeviceSegmentParams::nPagesMax, LinearDeviceSegmentParams::nPagesMin, NULL_PAGE_ID, paramShadowLogPrefix, pCache, pCheckpointThread, pSegmentFactory, readDeviceParams(), CompoundId::setBlockNum(), CompoundId::setDeviceId(), shadowDeviceId, shadowDeviceName, and DatabaseHeader::shadowRecoveryPageId.
Referenced by openSegments(), and prepareForRecovery().
00395 { 00396 SharedRandomAccessDevice pShadowDevice( 00397 new RandomAccessFileDevice(shadowDeviceName,shadowLogMode)); 00398 pCache->registerDevice(shadowDeviceId,pShadowDevice); 00399 00400 LinearDeviceSegmentParams deviceParams; 00401 readDeviceParams(paramShadowLogPrefix,shadowLogMode,deviceParams); 00402 CompoundId::setDeviceId(deviceParams.firstBlockId,shadowDeviceId); 00403 CompoundId::setBlockNum(deviceParams.firstBlockId,0); 00404 00405 if (forceTxns) { 00406 if (shadowLogMode.create) { 00407 // start allocating from beginning of device 00408 deviceParams.nPagesAllocated = 0; 00409 } else { 00410 // treat entire device as pre-allocated because we're 00411 // going to scan it during recovery 00412 deviceParams.nPagesAllocated = MAXU; 00413 } 00414 } else { 00415 deviceParams.nPagesAllocated = MAXU; 00416 deviceParams.nPagesIncrement = 0; 00417 deviceParams.nPagesMax = deviceParams.nPagesMin; 00418 } 00419 00420 SharedSegment pShadowSegment = 00421 pSegmentFactory->newLinearDeviceSegment( 00422 pCache, 00423 deviceParams); 00424 00425 PageId oldestPageId = NULL_PAGE_ID; 00426 if (!shadowLogMode.create) { 00427 oldestPageId = header.shadowRecoveryPageId; 00428 } 00429 00430 if (!forceTxns) { 00431 pShadowSegment = pSegmentFactory->newCircularSegment( 00432 pShadowSegment, 00433 pCheckpointThread, 00434 oldestPageId); 00435 } 00436 00437 return pSegmentFactory->newWALSegment(pShadowSegment); 00438 }
void Database::createDataDevice | ( | LinearDeviceSegmentParams & | ) | [private] |
Definition at line 440 of file Database.cpp.
References dataDeviceId, dataDeviceName, LinearDeviceSegmentParams::nPagesMin, openMode, paramDatabasePrefix, pCache, pDataDevice, readDeviceParams(), and shouldForceTxns().
Referenced by openSegments(), and prepareForRecovery().
00441 { 00442 readDeviceParams(paramDatabasePrefix,openMode,deviceParams); 00443 00444 FileSize initialSize = FileSize(0); 00445 if (shouldForceTxns()) { 00446 // include +2 for the database header pages 00447 initialSize = (deviceParams.nPagesMin + 2) * pCache->getPageSize(); 00448 } 00449 00450 pDataDevice = 00451 SharedRandomAccessDevice( 00452 new RandomAccessFileDevice( 00453 dataDeviceName, 00454 openMode, 00455 initialSize)); 00456 pCache->registerDevice(dataDeviceId,pDataDevice); 00457 }
void Database::createDataSegment | ( | SharedSegment | , | |
LinearDeviceSegmentParams & | ||||
) | [private] |
Definition at line 459 of file Database.cpp.
References areSnapshotsEnabled(), DeviceMode::create, dataDeviceId, LinearDeviceSegmentParams::firstBlockId, header, MAXU, LinearDeviceSegmentParams::nPagesAllocated, DatabaseHeader::onlineUuid, openMode, pCache, pDataSegment, pSegmentFactory, pTempSegment, pVersionedSegment, recoveryRequired, CompoundId::setBlockNum(), CompoundId::setDeviceId(), and DatabaseHeader::versionNumber.
Referenced by openSegments(), and prepareForRecovery().
00462 { 00463 // first data BlockId is located after the two database header pages 00464 CompoundId::setDeviceId(deviceParams.firstBlockId,dataDeviceId); 00465 CompoundId::setBlockNum(deviceParams.firstBlockId,2); 00466 00467 deviceParams.nPagesAllocated = MAXU; 00468 00469 SharedSegment pDataDeviceSegment = 00470 pSegmentFactory->newLinearDeviceSegment( 00471 pCache, 00472 deviceParams); 00473 00474 SharedSegment pVersionedDataSegment = 00475 pSegmentFactory->newVersionedSegment( 00476 pDataDeviceSegment, 00477 pShadowLogSegment, 00478 header.onlineUuid, 00479 header.versionNumber + (recoveryRequired ? 0 : 1)); 00480 00481 pVersionedSegment = SegmentFactory::dynamicCast<VersionedSegment *>( 00482 pVersionedDataSegment); 00483 00484 // If recovery is required, defer initializing the data segment for use 00485 // until after recovery has completed. 00486 if (areSnapshotsEnabled()) { 00487 pDataSegment = 00488 pSegmentFactory->newVersionedRandomAllocationSegment( 00489 pVersionedDataSegment, 00490 pTempSegment, 00491 openMode.create, 00492 recoveryRequired); 00493 } else { 00494 pDataSegment = 00495 pSegmentFactory->newRandomAllocationSegment( 00496 pVersionedDataSegment, 00497 openMode.create, 00498 recoveryRequired); 00499 } 00500 }
void Database::createTempSegment | ( | ) | [private] |
Definition at line 502 of file Database.cpp.
References DeviceMode::create, FileSystem::doesFileExist(), openMode, paramTempPrefix, pCache, pSegmentFactory, pTempSegment, readDeviceParams(), CompoundId::setBlockNum(), CompoundId::setDeviceId(), shouldForceTxns(), tempDeviceId, and tempDeviceName.
Referenced by openSegments(), and prepareForRecovery().
00503 { 00504 // If the temp device file already exists, use it; otherwise, create it. 00505 // There's no point in recreating it on every startup. But REVIEW: sizing 00506 // issues. 00507 DeviceMode tempMode = openMode; 00508 tempMode.create = !FileSystem::doesFileExist(tempDeviceName.c_str()); 00509 00510 LinearDeviceSegmentParams deviceParams; 00511 readDeviceParams(paramTempPrefix,tempMode,deviceParams); 00512 FileSize initialSize = FileSize(0); 00513 if (shouldForceTxns()) { 00514 initialSize = deviceParams.nPagesMin * pCache->getPageSize(); 00515 } 00516 00517 SharedRandomAccessDevice pTempDevice( 00518 new RandomAccessFileDevice(tempDeviceName,tempMode,initialSize)); 00519 pCache->registerDevice(tempDeviceId,pTempDevice); 00520 00521 // This forces the full device size to be used. 00522 tempMode.create = false; 00523 00524 // no header for temp device 00525 CompoundId::setDeviceId(deviceParams.firstBlockId,tempDeviceId); 00526 CompoundId::setBlockNum(deviceParams.firstBlockId,0); 00527 00528 SharedSegment pTempDeviceSegment = 00529 pSegmentFactory->newLinearDeviceSegment( 00530 pCache, 00531 deviceParams); 00532 00533 // Reformat any existing temp data. 00534 pTempSegment = 00535 pSegmentFactory->newRandomAllocationSegment( 00536 pTempDeviceSegment, 00537 true); 00538 }
void Database::allocateHeader | ( | ) | [private] |
Definition at line 591 of file Database.cpp.
References SegNodeLock< Node >::allocatePage(), dataDeviceId, FIRST_TXN_ID, LinearDeviceSegmentParams::firstBlockId, SegNodeLock< Node >::getNodeForWrite(), header, headerPageId1, headerPageId2, pCache, pHeaderSegment, pSegmentFactory, pTxnLog, CompoundId::setBlockNum(), CompoundId::setDeviceId(), and SegPageLock::unlock().
Referenced by openSegments().
00592 { 00593 LinearDeviceSegmentParams deviceParams; 00594 CompoundId::setDeviceId(deviceParams.firstBlockId,dataDeviceId); 00595 CompoundId::setBlockNum(deviceParams.firstBlockId,0); 00596 pHeaderSegment = 00597 pSegmentFactory->newLinearDeviceSegment( 00598 pCache, 00599 deviceParams); 00600 00601 SegmentAccessor segmentAccessor(pHeaderSegment,pCache); 00602 DatabaseHeaderPageLock headerPageLock(segmentAccessor); 00603 00604 PageId pageId; 00605 pTxnLog->setNextTxnId(FIRST_TXN_ID); 00606 pageId = headerPageLock.allocatePage(); 00607 assert(pageId == headerPageId1); 00608 headerPageLock.getNodeForWrite() = header; 00609 pageId = headerPageLock.allocatePage(); 00610 assert(pageId == headerPageId2); 00611 headerPageLock.getNodeForWrite() = header; 00612 headerPageLock.unlock(); 00613 pHeaderSegment->checkpoint(); 00614 }
void Database::writeHeader | ( | ) | [private] |
Definition at line 741 of file Database.cpp.
References SegNodeLock< Node >::getNodeForWrite(), SegPageLock::getPage(), header, headerPageId1, headerPageId2, SegPageLock::lockExclusive(), pCache, and pHeaderSegment.
Referenced by checkpointImpl(), prepareForRecovery(), and recoverPhysical().
00742 { 00743 // TODO: crc 00744 00745 // NOTE: use synchronous writes to guarantee that first write completes 00746 // before second one starts (otherwise a crash could leave both copies 00747 // corrupted) 00748 00749 SegmentAccessor segmentAccessor(pHeaderSegment,pCache); 00750 DatabaseHeaderPageLock headerPageLock(segmentAccessor); 00751 00752 headerPageLock.lockExclusive(headerPageId1); 00753 headerPageLock.getNodeForWrite() = header; 00754 pCache->flushPage(headerPageLock.getPage(),false); 00755 00756 headerPageLock.lockExclusive(headerPageId2); 00757 headerPageLock.getNodeForWrite() = header; 00758 pCache->flushPage(headerPageLock.getPage(),false); 00759 }
void Database::loadHeader | ( | bool | ) | [private] |
Definition at line 616 of file Database.cpp.
References SegNodeLock< Node >::checkMagicNumber(), dataDeviceId, LinearDeviceSegmentParams::firstBlockId, SegNodeLock< Node >::getNodeForRead(), header, headerPageId1, headerPageId2, SegPageLock::lockShared(), LogicalTxnLogCheckpointMemento::nextTxnId, LinearDeviceSegmentParams::nPagesAllocated, LinearDeviceSegmentParams::nPagesMax, pCache, pHeaderSegment, pSegmentFactory, pTxnLog, CompoundId::setBlockNum(), CompoundId::setDeviceId(), DatabaseHeader::txnLogCheckpointMemento, and DatabaseHeader::versionNumber.
Referenced by openSegments(), prepareForRecovery(), and restoreFromBackup().
00617 { 00618 LinearDeviceSegmentParams deviceParams; 00619 CompoundId::setDeviceId(deviceParams.firstBlockId,dataDeviceId); 00620 CompoundId::setBlockNum(deviceParams.firstBlockId,0); 00621 deviceParams.nPagesAllocated = 2; 00622 deviceParams.nPagesMax = 2; 00623 pHeaderSegment = 00624 pSegmentFactory->newLinearDeviceSegment( 00625 pCache, 00626 deviceParams); 00627 00628 SegmentAccessor segmentAccessor(pHeaderSegment,pCache); 00629 DatabaseHeaderPageLock headerPageLock1(segmentAccessor); 00630 headerPageLock1.lockShared(headerPageId1); 00631 if (!headerPageLock1.checkMagicNumber()) { 00632 throw DataFormatExcn(); 00633 } 00634 00635 DatabaseHeaderPageLock headerPageLock2(segmentAccessor); 00636 headerPageLock2.lockShared(headerPageId2); 00637 if (!headerPageLock2.checkMagicNumber()) { 00638 throw DataFormatExcn(); 00639 } 00640 00641 DatabaseHeader const &header1 = headerPageLock1.getNodeForRead(); 00642 DatabaseHeader const &header2 = headerPageLock2.getNodeForRead(); 00643 if (recovery) { 00644 // TODO: crc 00645 if (header2.versionNumber < header1.versionNumber) { 00646 header = header2; 00647 } else { 00648 header = header1; 00649 } 00650 } else { 00651 assert(header1.versionNumber == header2.versionNumber); 00652 // REVIEW: should assert other fields equal as well? 00653 header = header1; 00654 } 00655 if (pTxnLog) { 00656 TxnId nextTxnId = header.txnLogCheckpointMemento.nextTxnId; 00657 pTxnLog->setNextTxnId(nextTxnId); 00658 } 00659 }
void Database::closeDevices | ( | ) | [private] |
Definition at line 286 of file Database.cpp.
References dataDeviceId, pCache, pDataSegment, pHeaderSegment, pTempSegment, pTxnLog, pVersionedSegment, shadowDeviceId, tempDeviceId, and txnLogDeviceId.
Referenced by closeImpl(), and recover().
00287 { 00288 pVersionedSegment = NULL; 00289 pTxnLog.reset(); 00290 // REVIEW: have to explicitly close in case someone (like a recovery 00291 // factory) else still has a segment reference; should probably find a 00292 // better way to deal with this 00293 if (pDataSegment) { 00294 pDataSegment->close(); 00295 pDataSegment.reset(); 00296 } 00297 pHeaderSegment.reset(); 00298 if (pTempSegment) { 00299 pTempSegment->close(); 00300 pTempSegment.reset(); 00301 } 00302 00303 // for incomplete recovery or startup, these devices may not have been 00304 // opened yet 00305 if (pCache) { 00306 if (pCache->getDevice(txnLogDeviceId)) { 00307 pCache->unregisterDevice(txnLogDeviceId); 00308 } 00309 if (pCache->getDevice(shadowDeviceId)) { 00310 pCache->unregisterDevice(shadowDeviceId); 00311 } 00312 if (pCache->getDevice(dataDeviceId)) { 00313 pCache->unregisterDevice(dataDeviceId); 00314 } 00315 if (pCache->getDevice(tempDeviceId)) { 00316 pCache->unregisterDevice(tempDeviceId); 00317 } 00318 } 00319 }
void Database::deleteLogs | ( | ) | [private] |
Definition at line 321 of file Database.cpp.
References FileSystem::remove(), shadowDeviceName, and txnLogDeviceName.
Referenced by closeImpl(), and recover().
00322 { 00323 FileSystem::remove(shadowDeviceName.c_str()); 00324 FileSystem::remove(txnLogDeviceName.c_str()); 00325 00326 // TODO jvs 25-June-2005: here and in LogicalRecoveryLog, we should 00327 // be using ConfigMap to determine where to store txn logs 00328 // instead of current_path() 00329 directory_iterator end_itr; 00330 for (directory_iterator itr(current_path()); itr != end_itr; ++itr) { 00331 std::string filename = itr->path().filename(); 00332 // TODO jvs 25-June-2005: encapsulate filename parsing in 00333 // LogicalRecoveryLog 00334 if (filename.length() < 4) { 00335 continue; 00336 } 00337 if (filename.substr(0, 3) != "txn") { 00338 continue; 00339 } 00340 if (filename.substr(filename.length() - 4, 4) != ".dat") { 00341 continue; 00342 } 00343 FileSystem::remove(filename.c_str()); 00344 } 00345 }
void Database::openSegments | ( | ) | [private] |
Definition at line 186 of file Database.cpp.
References allocateHeader(), checkpointImpl(), DeviceMode::create, createDataDevice(), createDataSegment(), createShadowLog(), createTempSegment(), createTxnLog(), DeviceMode::direct, header, loadHeader(), DatabaseHeader::onlineUuid, openMode, pCheckpointThread, pUuidGenerator, TRACE_INFO, and DatabaseHeader::versionNumber.
Referenced by init(), and recover().
00187 { 00188 #ifdef NDEBUG 00189 FENNEL_TRACE(TRACE_INFO, "Fennel build: --with-optimization"); 00190 #else 00191 FENNEL_TRACE(TRACE_INFO, "Fennel build: --without-optimization"); 00192 #endif 00193 FENNEL_TRACE(TRACE_INFO, "opening database; process ID = " << getpid()); 00194 00195 pCheckpointThread = SharedCheckpointThread( 00196 new CheckpointThread(*this), 00197 ClosableObjectDestructor()); 00198 00199 createTempSegment(); 00200 00201 pUuidGenerator->generateUuid(header.onlineUuid); 00202 FENNEL_TRACE(TRACE_INFO, "online UUID = " << header.onlineUuid); 00203 00204 DeviceMode txnLogMode = openMode; 00205 txnLogMode.create = true; 00206 txnLogMode.direct = true; 00207 createTxnLog(txnLogMode); 00208 00209 LinearDeviceSegmentParams dataDeviceParams; 00210 createDataDevice(dataDeviceParams); 00211 00212 if (openMode.create) { 00213 // online UUID will be written out by allocateHeader 00214 allocateHeader(); 00215 } else { 00216 PseudoUuid newOnlineUuid = header.onlineUuid; 00217 loadHeader(false); 00218 // overwrite old online UUID; new one will be written out 00219 // by checkpoint below 00220 header.onlineUuid = newOnlineUuid; 00221 } 00222 00223 DeviceMode shadowMode = openMode; 00224 shadowMode.create = true; 00225 shadowMode.direct = true; 00226 00227 SharedSegment pShadowLogSegment = createShadowLog(shadowMode); 00228 createDataSegment(pShadowLogSegment, dataDeviceParams); 00229 00230 FENNEL_TRACE( 00231 TRACE_INFO, 00232 "database opened; page version = " 00233 << header.versionNumber); 00234 00235 if (!openMode.create) { 00236 checkpointImpl(); 00237 } 00238 00239 pCheckpointThread->start(); 00240 }
void Database::prepareForRecovery | ( | ) | [private] |
Definition at line 173 of file Database.cpp.
References createDataDevice(), createDataSegment(), createShadowLog(), createTempSegment(), loadHeader(), openMode, recoveryRequired, TRACE_WARNING, and writeHeader().
Referenced by init().
00174 { 00175 FENNEL_TRACE(TRACE_WARNING, "recovery required"); 00176 recoveryRequired = true; 00177 createTempSegment(); 00178 LinearDeviceSegmentParams dataDeviceParams; 00179 createDataDevice(dataDeviceParams); 00180 loadHeader(true); 00181 writeHeader(); 00182 SharedSegment pShadowLogSegment = createShadowLog(openMode); 00183 createDataSegment(pShadowLogSegment,dataDeviceParams); 00184 }
void Database::recoverPhysical | ( | CheckpointType | ) | [private] |
Definition at line 819 of file Database.cpp.
References CHECKPOINT_FLUSH_AND_UNMAP, DeviceMode::create, VersionedSegment::deallocateCheckpointedLog(), VersionedSegment::getVersionNumber(), header, isRecoveryRequired(), NULL_PAGE_ID, openMode, pDataSegment, pVersionedSegment, VersionedSegment::recover(), recoveryRequired, DatabaseHeader::shadowRecoveryPageId, TRACE_INFO, DatabaseHeader::versionNumber, and writeHeader().
Referenced by recover(), and recoverOnline().
00820 { 00821 assert(!openMode.create); 00822 assert(isRecoveryRequired()); 00823 recoveryRequired = false; 00824 00825 FENNEL_TRACE( 00826 TRACE_INFO, 00827 "recovery beginning; page version = " 00828 << header.versionNumber); 00829 00830 if (header.shadowRecoveryPageId != NULL_PAGE_ID) { 00831 pVersionedSegment->recover( 00832 pDataSegment, 00833 header.shadowRecoveryPageId, 00834 header.versionNumber); 00835 pDataSegment->checkpoint(checkpointType); 00836 header.versionNumber = pVersionedSegment->getVersionNumber(); 00837 header.shadowRecoveryPageId = NULL_PAGE_ID; 00838 writeHeader(); 00839 pVersionedSegment->deallocateCheckpointedLog( 00840 CHECKPOINT_FLUSH_AND_UNMAP); 00841 } 00842 }
void Database::readDeviceParams | ( | std::string | paramNamePrefix, | |
DeviceMode | deviceMode, | |||
LinearDeviceSegmentParams & | deviceParams | |||
) | [private] |
Definition at line 849 of file Database.cpp.
References configMap, DeviceMode::create, ConfigMap::getIntParam(), ConfigMap::isParamSet(), MAXU, LinearDeviceSegmentParams::nPagesAllocated, LinearDeviceSegmentParams::nPagesIncrement, LinearDeviceSegmentParams::nPagesMax, LinearDeviceSegmentParams::nPagesMin, paramIncSizeSuffix, paramInitSizeSuffix, and paramMaxSizeSuffix.
Referenced by createDataDevice(), createShadowLog(), createTempSegment(), and createTxnLogSegment().
00853 { 00854 deviceParams.nPagesMin = configMap.getIntParam( 00855 paramNamePrefix + paramInitSizeSuffix); 00856 if (configMap.isParamSet(paramNamePrefix + paramIncSizeSuffix)) { 00857 deviceParams.nPagesIncrement = configMap.getIntParam( 00858 paramNamePrefix + paramIncSizeSuffix); 00859 } 00860 deviceParams.nPagesMax = configMap.getIntParam( 00861 paramNamePrefix + paramMaxSizeSuffix); 00862 if (!deviceParams.nPagesMax) { 00863 deviceParams.nPagesMax = MAXU; 00864 } 00865 if (deviceMode.create) { 00866 deviceParams.nPagesAllocated = 0; 00867 } else { 00868 deviceParams.nPagesAllocated = MAXU; 00869 } 00870 }
void Database::cleanupBackupRestore | ( | bool | isBackup | ) | [private] |
Definition at line 1233 of file Database.cpp.
References disableDeallocateOld, pBackupRestoreDevice, pCheckpointThread, SegmentAccessor::pSegment, SegmentAccessor::reset(), and scratchAccessor.
Referenced by abortBackup(), completeBackup(), initiateBackup(), and restoreFromBackup().
01234 { 01235 if (pBackupRestoreDevice) { 01236 pBackupRestoreDevice.reset(); 01237 } 01238 if (scratchAccessor.pSegment) { 01239 scratchAccessor.reset(); 01240 } 01241 if (isBackup) { 01242 SXMutexSharedGuard actionMutexGuard( 01243 pCheckpointThread->getActionMutex()); 01244 disableDeallocateOld = false; 01245 } 01246 }
SharedDatabase Database::newDatabase | ( | SharedCache | pCache, | |
ConfigMap const & | configMap, | |||
DeviceMode | openMode, | |||
SharedTraceTarget | pTraceTarget, | |||
SharedPseudoUuidGenerator | pUuidGenerator = SharedPseudoUuidGenerator() | |||
) | [static] |
Definition at line 76 of file Database.cpp.
References Database().
Referenced by BackupRestoreTest::createSnapshotData(), DatabaseTest::loadDatabase(), BTreeTxnTest::testCaseSetUp(), DatabaseTest::testCreateEmpty(), BTreeTxnTest::testTxns(), and CmdInterpreter::visit().
00082 { 00083 if (!pUuidGenerator) { 00084 pUuidGenerator.reset(new PseudoUuidGenerator()); 00085 } 00086 SharedDatabase pDb = 00087 SharedDatabase( 00088 new Database( 00089 pCacheInit, configMapInit, openModeInit, pTraceTarget, 00090 pUuidGenerator), 00091 ClosableObjectDestructor()); 00092 pDb->init(); 00093 return pDb; 00094 }
const ConfigMap & Database::getConfigMap | ( | ) | const |
Definition at line 540 of file Database.cpp.
References configMap.
00541 { 00542 return configMap; 00543 }
SharedCache Database::getCache | ( | ) | const |
SharedSegmentFactory Database::getSegmentFactory | ( | ) | const |
Definition at line 581 of file Database.cpp.
References pSegmentFactory.
00582 { 00583 return pSegmentFactory; 00584 }
SharedSegment Database::getDataSegment | ( | ) | const |
Definition at line 550 of file Database.cpp.
References pDataSegment.
Referenced by getSegmentById().
00551 { 00552 return pDataSegment; 00553 }
SharedSegment Database::getTempSegment | ( | ) | const |
Definition at line 555 of file Database.cpp.
References pTempSegment.
Referenced by getSegmentById().
00556 { 00557 return pTempSegment; 00558 }
SharedCheckpointThread Database::getCheckpointThread | ( | ) | const |
Definition at line 560 of file Database.cpp.
References pCheckpointThread.
00561 { 00562 return pCheckpointThread; 00563 }
SharedSegment Database::getSegmentById | ( | SegmentId | segmentId, | |
SharedSegment | pDataSegment | |||
) | [virtual] |
Finds a segment by its SegmentId.
segmentId | the SegmentId to find | |
pDataSegment | the specific segment associated with a statement, if a specific segment must be used |
Implements SegmentMap.
Definition at line 565 of file Database.cpp.
References DEFAULT_DATA_SEGMENT_ID, getDataSegment(), getTempSegment(), and TEMP_SEGMENT_ID.
00568 { 00569 if (segmentId == TEMP_SEGMENT_ID) { 00570 return getTempSegment(); 00571 } else { 00572 assert(segmentId == DEFAULT_DATA_SEGMENT_ID); 00573 if (pDataSegment) { 00574 return pDataSegment; 00575 } else { 00576 return getDataSegment(); 00577 } 00578 } 00579 }
void Database::writeStats | ( | StatsTarget & | target | ) | [virtual] |
Writes a current stats snapshot to a StatsTarget.
target | receives the stats |
Implements StatsSource.
Definition at line 877 of file Database.cpp.
References SynchMonitoredObject::mutex, nCheckpoints, nCheckpointsStat, pCache, pDataSegment, pTempSegment, and StatsTarget::writeCounter().
00878 { 00879 pCache->writeStats(target); 00880 00881 StrictMutexGuard mutexGuard(mutex); 00882 target.writeCounter( 00883 "DatabaseCheckpoints", nCheckpointsStat); 00884 target.writeCounter( 00885 "DatabaseCheckpointsSinceInit", nCheckpoints); 00886 if (pDataSegment) { 00887 target.writeCounter( 00888 "DatabasePagesAllocated", pDataSegment->getAllocatedSizeInPages()); 00889 // +2 for the database header pages 00890 target.writeCounter( 00891 "DatabasePagesOccupiedHighWaterSinceInit", 00892 pDataSegment->getNumPagesOccupiedHighWater() + 2); 00893 target.writeCounter( 00894 "DatabasePagesExtendedSinceInit", 00895 pDataSegment->getNumPagesExtended()); 00896 } 00897 if (pTempSegment) { 00898 target.writeCounter( 00899 "TempPagesAllocated", pTempSegment->getAllocatedSizeInPages()); 00900 target.writeCounter( 00901 "TempPagesOccupiedHighWaterSinceInit", 00902 pTempSegment->getNumPagesOccupiedHighWater()); 00903 target.writeCounter( 00904 "TempPagesExtendedSinceInit", 00905 pTempSegment->getNumPagesExtended()); 00906 } 00907 nCheckpointsStat = 0; 00908 }
SharedLogicalTxnLog Database::getTxnLog | ( | ) | const |
Definition at line 586 of file Database.cpp.
References pTxnLog.
00587 { 00588 return pTxnLog; 00589 }
StoredTypeDescriptorFactory const & Database::getTypeFactory | ( | ) | const |
Definition at line 872 of file Database.cpp.
References typeFactory.
00873 { 00874 return typeFactory; 00875 }
bool Database::isRecoveryRequired | ( | ) | const |
Definition at line 844 of file Database.cpp.
References recoveryRequired.
Referenced by checkpointImpl(), closeImpl(), and recoverPhysical().
00845 { 00846 return recoveryRequired; 00847 }
bool Database::shouldForceTxns | ( | ) | const |
Definition at line 910 of file Database.cpp.
References forceTxns.
Referenced by createDataDevice(), and createTempSegment().
00911 { 00912 return forceTxns; 00913 }
bool Database::areSnapshotsEnabled | ( | ) | const |
Definition at line 915 of file Database.cpp.
References disableSnapshots, and forceTxns.
Referenced by closeImpl(), createDataSegment(), initiateBackup(), and restoreFromBackup().
00916 { 00917 return (forceTxns && !disableSnapshots); 00918 }
void Database::recoverOnline | ( | ) |
Definition at line 761 of file Database.cpp.
References CHECKPOINT_FLUSH_ALL, checkpointImpl(), forceTxns, VersionedSegment::getOnlineRecoveryPageId(), header, VersionedSegment::prepareOnlineRecovery(), pVersionedSegment, recoverPhysical(), recoveryRequired, and DatabaseHeader::shadowRecoveryPageId.
00762 { 00763 // REVIEW jvs 8-Aug-2006: This procedure has one questionable aspect, 00764 // which is that it leaves images of newly allocated pages in cache. 00765 // Updated pages are handled by recovery from the log, but newly allocated 00766 // pages are not. They will be clean, so they shouldn't really cause any 00767 // trouble, but their presence could be, at a minimum, confusing. 00768 00769 assert(forceTxns); 00770 header.shadowRecoveryPageId = 00771 pVersionedSegment->getOnlineRecoveryPageId(); 00772 pVersionedSegment->prepareOnlineRecovery(); 00773 recoveryRequired = true; 00774 00775 // after recovery, flush recovered data pages; no need to discard them 00776 recoverPhysical(CHECKPOINT_FLUSH_ALL); 00777 00778 // this will bump up version number to be used by further page writes 00779 checkpointImpl(CHECKPOINT_FLUSH_ALL); 00780 }
void Database::recover | ( | LogicalTxnParticipantFactory & | txnParticipantFactory | ) |
Definition at line 782 of file Database.cpp.
References CHECKPOINT_FLUSH_AND_UNMAP, closeDevices(), createTxnLogSegment(), deleteLogs(), CompoundId::getPageId(), header, LogicalTxnLogCheckpointMemento::logPosition, LogicalRecoveryLog::newLogicalRecoveryLog(), DatabaseHeader::onlineUuid, openMode, openSegments(), pCache, pSegmentFactory, recoverPhysical(), SegmentAccessor::reset(), SegStreamPosition::segByteId, TRACE_INFO, and DatabaseHeader::txnLogCheckpointMemento.
00784 { 00785 recoverPhysical(CHECKPOINT_FLUSH_AND_UNMAP); 00786 00787 // REVIEW: are shadows being correctly logged during recovery? They have 00788 // to be, otherwise we can't re-recover after a failed recovery. 00789 00790 // TODO: encapsulate memento->PageId translation in txn somewhere 00791 SharedSegment pTxnLogSegment = createTxnLogSegment( 00792 openMode, 00793 CompoundId::getPageId( 00794 header.txnLogCheckpointMemento.logPosition.segByteId)); 00795 00796 SegmentAccessor logSegmentAccessor(pTxnLogSegment,pCache); 00797 00798 SharedLogicalRecoveryLog pRecoveryLog = 00799 LogicalRecoveryLog::newLogicalRecoveryLog( 00800 txnParticipantFactory, 00801 logSegmentAccessor, 00802 header.onlineUuid, 00803 pSegmentFactory); 00804 logSegmentAccessor.reset(); 00805 00806 pRecoveryLog->recover(header.txnLogCheckpointMemento); 00807 assert(pRecoveryLog.unique()); 00808 pRecoveryLog.reset(); 00809 assert(pTxnLogSegment.unique()); 00810 pTxnLogSegment.reset(); 00811 00812 closeDevices(); 00813 deleteLogs(); 00814 FENNEL_TRACE(TRACE_INFO, "recovery completed"); 00815 00816 openSegments(); 00817 }
void Database::checkpointImpl | ( | CheckpointType | = CHECKPOINT_FLUSH_ALL |
) |
Definition at line 666 of file Database.cpp.
References CHECKPOINT_DISCARD, CHECKPOINT_FLUSH_FUZZY, SynchMonitoredObject::condition, VersionedSegment::deallocateCheckpointedLog(), forceTxns, VersionedSegment::getOnlineRecoveryPageId(), VersionedSegment::getRecoveryPageId(), VersionedSegment::getVersionNumber(), header, isRecoveryRequired(), SynchMonitoredObject::mutex, nCheckpoints, nCheckpointsStat, pDataSegment, pTxnLog, pVersionedSegment, recoveryRequired, DatabaseHeader::shadowRecoveryPageId, DatabaseHeader::txnLogCheckpointMemento, DatabaseHeader::versionNumber, and writeHeader().
Referenced by closeImpl(), openSegments(), recoverOnline(), and CheckpointThread::run().
00667 { 00668 assert(!isRecoveryRequired()); 00669 00670 if (checkpointType == CHECKPOINT_DISCARD) { 00671 recoveryRequired = true; 00672 // NOTE jvs 6-Mar-2006: record this BEFORE anything else, 00673 // since pDataSegment->checkpoint(CHECKPOINT_DISCARD) will 00674 // destroy it 00675 header.shadowRecoveryPageId = 00676 pVersionedSegment->getOnlineRecoveryPageId(); 00677 pDataSegment->checkpoint(checkpointType); 00678 if (!forceTxns) { 00679 // REVIEW jvs 8-Mar-2006: I put in the forceTxns test 00680 // because when forceTxn is true, we actually use 00681 // CHECKPOINT_DISCARD for rollback, and there we DON'T 00682 // want to remove the other uncommitted transactions, 00683 // which is a side-effect of LogicalTxnLog::checkpoint(DISCARD). 00684 // Really, for forceTxns, we shouldn't be using 00685 // LogicalTxnLog at all. And we should discriminate 00686 // between CHECKPOINT_DISCARD used to simulate a crash in 00687 // tests and CHECKPOINT_DISCARD used to implement rollback 00688 // as part of forceTxns. 00689 LogicalTxnLogCheckpointMemento crashMemento; 00690 pTxnLog->checkpoint(crashMemento,checkpointType); 00691 } 00692 return; 00693 } 00694 00695 header.versionNumber = pVersionedSegment->getVersionNumber(); 00696 if (checkpointType == CHECKPOINT_FLUSH_FUZZY) { 00697 header.versionNumber--; 00698 } 00699 pDataSegment->checkpoint(checkpointType); 00700 header.shadowRecoveryPageId = pVersionedSegment->getRecoveryPageId(); 00701 pTxnLog->checkpoint( 00702 header.txnLogCheckpointMemento, 00703 checkpointType); 00704 writeHeader(); 00705 pVersionedSegment->deallocateCheckpointedLog(checkpointType); 00706 pTxnLog->deallocateCheckpointedLog( 00707 header.txnLogCheckpointMemento,checkpointType); 00708 00709 StrictMutexGuard mutexGuard(mutex); 00710 // TODO: provide a counter which records the amount of data flushed by the 00711 // checkpoint 00712 ++nCheckpointsStat; 00713 ++nCheckpoints; 00714 condition.notify_all(); 00715 }
void Database::requestCheckpoint | ( | CheckpointType | checkpointType, | |
bool | async | |||
) |
Receives request for a checkpoint.
checkpointType | must be CHECKPOINT_FLUSH_FUZZY or CHECKPOINT_FLUSH_ALL | |
async | if true, just schedule checkpoint and return; if false, wait for completion |
Definition at line 717 of file Database.cpp.
References CHECKPOINT_FLUSH_ALL, CHECKPOINT_FLUSH_FUZZY, SynchMonitoredObject::condition, forceTxns, SynchMonitoredObject::mutex, nCheckpoints, and pCheckpointThread.
Referenced by deallocateOldPages().
00718 { 00719 StrictMutexGuard mutexGuard(mutex); 00720 uint nCheckpointsBefore = nCheckpoints; 00721 mutexGuard.unlock(); 00722 00723 if (forceTxns && (checkpointType == CHECKPOINT_FLUSH_FUZZY)) { 00724 // fuzzy checkpoints aren't meaningful in forceTxns mode, 00725 // so treat them as sharp 00726 checkpointType = CHECKPOINT_FLUSH_ALL; 00727 } 00728 00729 pCheckpointThread->requestCheckpoint(checkpointType); 00730 00731 if (async) { 00732 return; 00733 } 00734 00735 mutexGuard.lock(); 00736 while (nCheckpoints == nCheckpointsBefore) { 00737 condition.wait(mutexGuard); 00738 } 00739 }
void Database::deallocateOldPages | ( | TxnId | oldestLabelCsn | ) |
Deallocates old snapshot pages that are no longer referenced by any active transactions, as well as active labels marking snapshots in time.
oldestLabelCsn | the csn of the oldest active label; set to NULL_TXN_ID if there are no active labels |
Definition at line 920 of file Database.cpp.
References CHECKPOINT_FLUSH_ALL, VersionedRandomAllocationSegment::deallocateOldPages(), disableDeallocateOld, VersionedRandomAllocationSegment::getOldPageIds(), min(), NULL_TXN_ID, pCheckpointThread, pDataSegment, pTxnLog, and requestCheckpoint().
00921 { 00922 uint iSegAlloc = 0; 00923 ExtentNum extentNum = 0; 00924 // REVIEW zfong 3/12/07 - Determine a good value for numPages. This 00925 // corresponds to the number of pages we will deallocate during a single 00926 // iteration. We will be holding the checkpoint mutex for the duration 00927 // of an iteration so we don't want to make the value too big. But at 00928 // the same time, we don't want to make it too small either, because it 00929 // would then require a large number of iterations to clean out all old 00930 // pages. 00931 uint numPages = 100; 00932 00933 // Determine the oldest active txnId. 00934 TxnId oldestActiveTxnId = pTxnLog->getOldestActiveTxnId(); 00935 00936 // Take the minimum of the oldest active txnId and the 00937 // oldest active label + 1, if there are any active labels. 00938 // +1 because txns using that label will have ids bigger than that 00939 // label's csn. 00940 TxnId oldestTxnId; 00941 if (oldestLabelCsn == NULL_TXN_ID) { 00942 oldestTxnId = oldestActiveTxnId; 00943 } else { 00944 oldestTxnId = std::min(oldestActiveTxnId, oldestLabelCsn + 1); 00945 } 00946 00947 // Gather a batch of old pageIds and then deallocate them. After each 00948 // deallocation, issue a checkpoint to flush the modified allocation 00949 // node pages. Continue this in a loop until we've read through all 00950 // allocation node pages. 00951 00952 PageSet oldPageSet; 00953 VersionedRandomAllocationSegment *pVersionedRandomSegment = 00954 SegmentFactory::dynamicCast<VersionedRandomAllocationSegment *>( 00955 pDataSegment); 00956 bool morePages = true; 00957 do { 00958 morePages = 00959 pVersionedRandomSegment->getOldPageIds( 00960 iSegAlloc, 00961 extentNum, 00962 oldestTxnId, 00963 numPages, 00964 oldPageSet); 00965 00966 // Hold the checkpoint mutex while deallocating old pages, if there 00967 // are pages to deallocate. 00968 if (!oldPageSet.empty()) { 00969 SXMutexSharedGuard actionMutexGuard( 00970 pCheckpointThread->getActionMutex()); 00971 if (disableDeallocateOld) { 00972 return; 00973 } 00974 pVersionedRandomSegment->deallocateOldPages( 00975 oldPageSet, 00976 oldestTxnId); 00977 00978 actionMutexGuard.unlock(); 00979 requestCheckpoint(CHECKPOINT_FLUSH_ALL, false); 00980 oldPageSet.clear(); 00981 } 00982 } while (morePages); 00983 }
void Database::setLastCommittedTxnId | ( | TxnId | txnId | ) |
Saves the id of the last committed transaction.
txnId | id of the last committed transaction |
TxnId Database::getLastCommittedTxnId | ( | ) |
Definition at line 661 of file Database.cpp.
References header, LogicalTxnLogCheckpointMemento::nextTxnId, and DatabaseHeader::txnLogCheckpointMemento.
Referenced by initiateBackup(), and restoreFromBackup().
00662 { 00663 return header.txnLogCheckpointMemento.nextTxnId - 1; 00664 }
TxnId Database::initiateBackup | ( | const std::string & | backupFilePathname, | |
bool | checkSpaceRequirements, | |||
FileSize | spacePadding, | |||
TxnId | lowerBoundCsn, | |||
const std::string & | compressionProgram, | |||
FileSize & | dataDeviceSize, | |||
const volatile bool & | aborted | |||
) |
Initiates a backup of the data segment.
Backs up the header pages and the allocation node pages.
backupFilePathname | pathname of the backup file | |
checkSpaceRequirements | if true, make sure file system space is available to perform the backup of data pages | |
spacePadding | if non-zero, the amount of padding to add to the space requirements for the backup to proceed | |
lowerBoundCsn | the lower bound allocation csn that determines which pages need to be backed up; if the lower bound is set to NULL_TXN_ID, then that indicates that there is no lower bound; otherwise, the lower bound is exclusive | |
compressionProgram | if non-empty string, the name of the program used to compress the backup file | |
dataDeviceSize | returns the size of the data device in bytes | |
aborted | reference to a flag indicating whether the backup should be aborted |
Definition at line 985 of file Database.cpp.
References areSnapshotsEnabled(), cleanupBackupRestore(), disableDeallocateOld, FileSystem::getDiskFreeSpace(), getLastCommittedTxnId(), headerPageId1, headerPageId2, SegPageBackupRestoreDevice::newSegPageBackupRestoreDevice(), pBackupRestoreDevice, pCache, pCheckpointThread, pDataDevice, pDataSegment, pHeaderSegment, pSegmentFactory, scratchAccessor, and TRACE_FINE.
00993 { 00994 FENNEL_TRACE(TRACE_FINE, "Started Fennel metadata backup"); 00995 00996 // Snapshots must be enabled 00997 if (!areSnapshotsEnabled()) { 00998 throw FennelExcn( 00999 FennelResource::instance().unsupportedOperation("System backup")); 01000 } 01001 01002 // Hold the checkpoint mutex while backing up the header and allocation 01003 // node pages 01004 SXMutexSharedGuard actionMutexGuard(pCheckpointThread->getActionMutex()); 01005 01006 // Another backup should not have already been initiated 01007 assert(!disableDeallocateOld); 01008 assert(pBackupRestoreDevice == NULL); 01009 01010 // The upper bound csn for this backup is the txnId of the last committed, 01011 // write txn. Note that the next txnId to be assigned may be a larger 01012 // value because of read-only txns. But we don't care about read-only 01013 // txns. We just want the txnId that's in sync with what's reflected in 01014 // the header. 01015 TxnId upperBoundCsn = getLastCommittedTxnId(); 01016 01017 disableDeallocateOld = true; 01018 dataDeviceSize = pDataDevice->getSizeInBytes(); 01019 01020 // Use the prefetch setting to determine how many scratch pages to 01021 // allocate. Note that these scratch pages are not being accounted 01022 // for in the resource governor and come from the reserve pool that 01023 // the resource governor currently sets aside. 01024 uint nScratchPages, rate; 01025 pCache->getPrefetchParams(nScratchPages, rate); 01026 01027 scratchAccessor = pSegmentFactory->newScratchSegment(pCache); 01028 pBackupRestoreDevice = 01029 SegPageBackupRestoreDevice::newSegPageBackupRestoreDevice( 01030 backupFilePathname, 01031 #ifdef __MSVC__ 01032 "wb", 01033 #else 01034 "w", 01035 #endif 01036 compressionProgram, 01037 nScratchPages, 01038 2, 01039 scratchAccessor, 01040 pCache->getDeviceAccessScheduler(*pDataDevice), 01041 pDataDevice); 01042 VersionedRandomAllocationSegment *pVRSegment = 01043 SegmentFactory::dynamicCast<VersionedRandomAllocationSegment *>( 01044 pDataSegment); 01045 01046 try { 01047 pBackupRestoreDevice->backupPage( 01048 pHeaderSegment->translatePageId(headerPageId1)); 01049 pBackupRestoreDevice->backupPage( 01050 pHeaderSegment->translatePageId(headerPageId2)); 01051 // First wait for writes of the header pages to complete before backing 01052 // up the allocation node pages. 01053 pBackupRestoreDevice->waitForPendingWrites(); 01054 BlockNum nDataPages = 01055 pVRSegment->backupAllocationNodes( 01056 pBackupRestoreDevice, 01057 checkSpaceRequirements, 01058 lowerBoundCsn, 01059 upperBoundCsn, 01060 aborted); 01061 01062 // Verify space if specified, now that we know how many data pages 01063 // will be backed up 01064 if (checkSpaceRequirements) { 01065 FileSize spaceAvailable; 01066 FileSystem::getDiskFreeSpace( 01067 backupFilePathname.c_str(), 01068 spaceAvailable); 01069 FileSize spaceRequired = 01070 nDataPages * pDataSegment->getFullPageSize(); 01071 // TODO zfong 9/16/08 - Revisit the compression factor after more 01072 // testing. Set conservatively to 5, for now. 01073 if (compressionProgram.length() != 0) { 01074 spaceRequired /= 5; 01075 } 01076 spaceRequired += spacePadding; 01077 if (spaceAvailable < spaceRequired) { 01078 throw FennelExcn(FennelResource::instance().outOfBackupSpace()); 01079 } 01080 } 01081 } catch (...) { 01082 cleanupBackupRestore(true); 01083 // abort exception takes precedence 01084 if (aborted) { 01085 FENNEL_TRACE(TRACE_FINE, "abort detected"); 01086 throw AbortExcn(); 01087 } else { 01088 throw; 01089 } 01090 } 01091 01092 FENNEL_TRACE(TRACE_FINE, "Finished Fennel metadata backup"); 01093 return upperBoundCsn; 01094 }
void Database::completeBackup | ( | TxnId | lowerBoundCsn, | |
TxnId | upperBoundCsn, | |||
const volatile bool & | aborted | |||
) |
Completes the remainder of a backup by backing up the data pages that have allocationCsn's in between two specified bounds.
If the lower bound is set to NULL_TXN_ID, then that indicates that there is no lower bound; otherwise, the lower bound is exclusive. There must always be an upper bound and it is inclusive.
lowerBoundCsn | the lower bound allocation csn | |
upperBoundCsn | the upper bound allocation csn | |
aborted | reference to a flag indicating whether the backup should be aborted |
Definition at line 1096 of file Database.cpp.
References VersionedRandomAllocationSegment::backupDataPages(), cleanupBackupRestore(), disableDeallocateOld, pBackupRestoreDevice, pDataSegment, and TRACE_FINE.
01100 { 01101 FENNEL_TRACE(TRACE_FINE, "Started Fennel data page backup"); 01102 assert(disableDeallocateOld); 01103 assert(pBackupRestoreDevice != NULL); 01104 01105 VersionedRandomAllocationSegment *pVRSegment = 01106 SegmentFactory::dynamicCast<VersionedRandomAllocationSegment *>( 01107 pDataSegment); 01108 try { 01109 pVRSegment->backupDataPages( 01110 pBackupRestoreDevice, 01111 lowerBoundCsn, 01112 upperBoundCsn, 01113 aborted); 01114 cleanupBackupRestore(true); 01115 } catch (...) { 01116 cleanupBackupRestore(true); 01117 // abort exception takes precedence 01118 if (aborted) { 01119 FENNEL_TRACE(TRACE_FINE, "abort detected"); 01120 throw AbortExcn(); 01121 } else { 01122 throw; 01123 } 01124 } 01125 01126 FENNEL_TRACE(TRACE_FINE, "Finished Fennel data page backup"); 01127 }
void Database::abortBackup | ( | ) |
Aborts a backup that may or may not have been previously initiated.
This is necessary to perform cleanup on the backup in case an error occurred after the backup was initiated, but before there was a chance to complete it.
Definition at line 1129 of file Database.cpp.
References cleanupBackupRestore(), and TRACE_FINE.
01130 { 01131 FENNEL_TRACE(TRACE_FINE, "Aborting Fennel backup"); 01132 cleanupBackupRestore(true); 01133 }
void Database::restoreFromBackup | ( | const std::string & | backupFilePathname, | |
FileSize | newSize, | |||
const std::string & | compressionProgram, | |||
TxnId | lowerBoundCsn, | |||
TxnId | upperBoundCsn, | |||
const volatile bool & | aborted | |||
) |
Restores the data segment from a backup file.
The data pages in the backup file correspond to pages with allocationCsn's in between a lower and upper bound. If the lower bound is set to NULL_TXN_ID, then that indicates that there is no lower bound; otherwise, the lower bound is exclusive. There must always be an upper bound and it is inclusive.
backupFilePathname | pathname of the backup file | |
newSize | the size the data segment will be extended to by the restore | |
compressionProgram | if non-empty string, the name of the program used to compress the backup file | |
lowerBoundCsn | the lower bound allocation csn | |
upperBoundCsn | the upper bound allocation csn | |
aborted | reference to a flag indicating whether the restore should be aborted |
Definition at line 1135 of file Database.cpp.
References areSnapshotsEnabled(), CHECKPOINT_FLUSH_AND_UNMAP, cleanupBackupRestore(), getLastCommittedTxnId(), header, headerPageId1, headerPageId2, loadHeader(), SegPageBackupRestoreDevice::newSegPageBackupRestoreDevice(), NULL_PAGE_ID, NULL_TXN_ID, DatabaseHeader::onlineUuid, pBackupRestoreDevice, pCache, pDataDevice, pDataSegment, pHeaderSegment, pSegmentFactory, pVersionedSegment, VersionedSegment::recover(), VersionedRandomAllocationSegment::restoreFromBackup(), scratchAccessor, TRACE_FINE, and DatabaseHeader::versionNumber.
01142 { 01143 FENNEL_TRACE(TRACE_FINE, "Started Fennel restore"); 01144 01145 // Snapshots must be enabled 01146 if (!areSnapshotsEnabled()) { 01147 throw FennelExcn( 01148 FennelResource::instance().unsupportedOperation("System restore")); 01149 } 01150 01151 // Verify that the last committed csn in the database header matches the 01152 // lower bound csn. 01153 if (lowerBoundCsn != NULL_TXN_ID) { 01154 TxnId headerTxnId = getLastCommittedTxnId(); 01155 if (headerTxnId != lowerBoundCsn) { 01156 throw FennelExcn( 01157 FennelResource::instance().mismatchedRestore()); 01158 } 01159 } 01160 01161 pDataDevice->setSizeInBytes(newSize); 01162 01163 VersionedRandomAllocationSegment *pVRSegment = 01164 SegmentFactory::dynamicCast<VersionedRandomAllocationSegment *>( 01165 pDataSegment); 01166 01167 uint nScratchPages, rate; 01168 pCache->getPrefetchParams(nScratchPages, rate); 01169 01170 scratchAccessor = 01171 pSegmentFactory->newScratchSegment(pCache); 01172 pBackupRestoreDevice = 01173 SegPageBackupRestoreDevice::newSegPageBackupRestoreDevice( 01174 backupFilePathname, 01175 #ifdef __MSVC__ 01176 "rb", 01177 #else 01178 "r", 01179 #endif 01180 compressionProgram, 01181 nScratchPages, 01182 0, 01183 scratchAccessor, 01184 pCache->getDeviceAccessScheduler(*pDataDevice), 01185 pDataDevice); 01186 01187 // Flush and unmap pages from the cache that will be restored, i.e., any 01188 // VersionedRandomAllocationSegment or database header pages, including 01189 // the header page just read above. We need to unmap these pages to 01190 // ensure that the restore doesn't read old pages. 01191 MappedPageListenerPredicate dataPredicate(*pVRSegment); 01192 pCache->checkpointPages(dataPredicate, CHECKPOINT_FLUSH_AND_UNMAP); 01193 MappedPageListenerPredicate headerPredicate(*pHeaderSegment); 01194 pCache->checkpointPages(headerPredicate, CHECKPOINT_FLUSH_AND_UNMAP); 01195 01196 try { 01197 // Restore the rest of the pages, including the database header pages 01198 pBackupRestoreDevice->restorePage( 01199 pHeaderSegment->translatePageId(headerPageId1)); 01200 pBackupRestoreDevice->restorePage( 01201 pHeaderSegment->translatePageId(headerPageId2)); 01202 pVRSegment->restoreFromBackup( 01203 pBackupRestoreDevice, 01204 lowerBoundCsn, 01205 upperBoundCsn, 01206 aborted); 01207 cleanupBackupRestore(false); 01208 } catch (...) { 01209 cleanupBackupRestore(false); 01210 // abort exception takes precedence 01211 if (aborted) { 01212 FENNEL_TRACE(TRACE_FINE, "abort detected"); 01213 throw AbortExcn(); 01214 } else { 01215 throw; 01216 } 01217 } 01218 01219 // Reload the header pages so future checkpoints will flush the 01220 // restored data. Issue a recover call on the versioned segment 01221 // to reset the version number and online uuid to the values that are 01222 // now in the header. 01223 loadHeader(false); 01224 pVersionedSegment->recover( 01225 pDataSegment, 01226 NULL_PAGE_ID, 01227 header.versionNumber, 01228 header.onlineUuid); 01229 01230 FENNEL_TRACE(TRACE_FINE, "Finished Fennel restore"); 01231 }
bool ClosableObject::isClosed | ( | ) | const [inline, inherited] |
Definition at line 58 of file ClosableObject.h.
00059 { 00060 return !needsClose; 00061 }
void ClosableObject::close | ( | ) | [inherited] |
Closes this object, releasing any unallocated resources.
Reimplemented in CollectExecStream, CorrelationJoinExecStream, LcsClusterAppendExecStream, and LcsClusterReplaceExecStream.
Definition at line 39 of file ClosableObject.cpp.
References ClosableObject::closeImpl(), and ClosableObject::needsClose.
Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), LcsRowScanBaseExecStream::closeImpl(), ExecStreamGraphImpl::closeImpl(), FlatFileBuffer::open(), ClosableObjectDestructor::operator()(), and Segment::~Segment().
00040 { 00041 if (!needsClose) { 00042 return; 00043 } 00044 needsClose = false; 00045 closeImpl(); 00046 }
void TraceSource::initTraceSource | ( | SharedTraceTarget | pTraceTarget, | |
std::string | name | |||
) | [virtual, inherited] |
For use when initialization has to be deferred until after construction.
pTraceTarget | the TraceTarget to which messages will be sent | |
name | the name of this source |
Definition at line 46 of file TraceSource.cpp.
References TraceSource::isTracing(), TraceSource::minimumLevel, TraceSource::name, TraceSource::pTraceTarget, and TRACE_OFF.
Referenced by TestBase::beforeTestCase(), TestBase::TestBase(), and TraceSource::TraceSource().
00049 { 00050 assert(!pTraceTarget.get()); 00051 00052 pTraceTarget = pTraceTargetInit; 00053 name = nameInit; 00054 if (isTracing()) { 00055 minimumLevel = pTraceTarget->getSourceTraceLevel(name); 00056 } else { 00057 minimumLevel = TRACE_OFF; 00058 } 00059 }
void TraceSource::trace | ( | TraceLevel | level, | |
std::string | message | |||
) | const [inherited] |
Records a trace message.
Normally only called via FENNEL_TRACE.
level | severity level of event being trace | |
message | the text of the message |
Definition at line 61 of file TraceSource.cpp.
References TraceSource::getTraceTarget(), TraceSource::isTracing(), TraceSource::name, and TraceTarget::notifyTrace().
Referenced by Calculator::exec(), and ExecStreamScheduler::traceStreamBufferContents().
00062 { 00063 if (isTracing()) { 00064 getTraceTarget().notifyTrace(name,level,message); 00065 } 00066 }
bool TraceSource::isTracing | ( | ) | const [inline, inherited] |
Definition at line 88 of file TraceSource.h.
Referenced by TraceSource::initTraceSource(), CalcExecStream::prepare(), and TraceSource::trace().
00089 { 00090 return pTraceTarget.get() ? true : false; 00091 }
bool TraceSource::isTracingLevel | ( | TraceLevel | level | ) | const [inline, inherited] |
Determines whether a particular level is being traced.
level | trace level to test |
Definition at line 100 of file TraceSource.h.
Referenced by ExecStreamScheduler::addGraph(), SimpleExecStreamGovernor::assignCachePages(), SimpleExecStreamGovernor::distributeCachePages(), Calculator::exec(), ExecStreamScheduler::ExecStreamScheduler(), LcsClusterNodeWriter::getLastClusterPageForWrite(), LcsClusterNodeWriter::moveFromTempToIndex(), JavaSinkExecStream::stuffByteBuffer(), and ExecStreamScheduler::traceStreamBuffers().
00101 { 00102 return level >= minimumLevel; 00103 }
TraceTarget& TraceSource::getTraceTarget | ( | ) | const [inline, inherited] |
Definition at line 108 of file TraceSource.h.
Referenced by TraceSource::trace().
00109 { 00110 assert(isTracing()); 00111 return *(pTraceTarget.get()); 00112 }
SharedTraceTarget TraceSource::getSharedTraceTarget | ( | ) | const [inline, inherited] |
Definition at line 117 of file TraceSource.h.
Referenced by init(), LcsClusterAppendExecStream::initLoad(), and CalcExecStream::prepare().
00118 { 00119 return pTraceTarget; 00120 }
std::string TraceSource::getTraceSourceName | ( | ) | const [inline, inherited] |
Gets the name of this source.
Useful to construct nested names for subcomponents that are also TraceSources.
Definition at line 127 of file TraceSource.h.
Referenced by LcsClusterAppendExecStream::initLoad().
00128 { 00129 return name; 00130 }
void TraceSource::setTraceSourceName | ( | std::string const & | n | ) | [inline, inherited] |
Sets the name of this source.
Useful to construct dynamic names for fine-grained filtering.
Definition at line 136 of file TraceSource.h.
00137 { 00138 name = n; 00139 }
TraceLevel TraceSource::getMinimumTraceLevel | ( | ) | const [inline, inherited] |
void TraceSource::disableTracing | ( | ) | [inherited] |
Definition at line 68 of file TraceSource.cpp.
References TraceSource::minimumLevel, TraceSource::pTraceTarget, and TRACE_OFF.
Referenced by TestBase::afterTestCase().
00069 { 00070 pTraceTarget.reset(); 00071 minimumLevel = TRACE_OFF; 00072 }
DeviceId Database::dataDeviceId [private] |
Definition at line 57 of file Database.h.
Referenced by allocateHeader(), closeDevices(), createDataDevice(), createDataSegment(), init(), and loadHeader().
Definition at line 59 of file Database.h.
Referenced by createDataDevice(), initiateBackup(), and restoreFromBackup().
DeviceId Database::tempDeviceId [private] |
Definition at line 61 of file Database.h.
Referenced by closeDevices(), createTempSegment(), and init().
DeviceId Database::shadowDeviceId [private] |
Definition at line 63 of file Database.h.
Referenced by closeDevices(), createShadowLog(), and init().
DeviceId Database::txnLogDeviceId [private] |
Definition at line 65 of file Database.h.
Referenced by closeDevices(), createTxnLogSegment(), and init().
std::string Database::dataDeviceName [private] |
std::string Database::tempDeviceName [private] |
std::string Database::shadowDeviceName [private] |
Definition at line 71 of file Database.h.
Referenced by createShadowLog(), deleteLogs(), and init().
std::string Database::txnLogDeviceName [private] |
Definition at line 73 of file Database.h.
Referenced by createTxnLogSegment(), deleteLogs(), and init().
SharedCache Database::pCache [private] |
Definition at line 75 of file Database.h.
Referenced by allocateHeader(), closeDevices(), createDataDevice(), createDataSegment(), createShadowLog(), createTempSegment(), createTxnLog(), createTxnLogSegment(), getCache(), initiateBackup(), loadHeader(), recover(), restoreFromBackup(), writeHeader(), and writeStats().
Definition at line 77 of file Database.h.
Referenced by allocateHeader(), createDataSegment(), createShadowLog(), createTempSegment(), createTxnLog(), createTxnLogSegment(), getSegmentFactory(), init(), initiateBackup(), loadHeader(), recover(), and restoreFromBackup().
SharedSegment Database::pHeaderSegment [private] |
Definition at line 79 of file Database.h.
Referenced by allocateHeader(), closeDevices(), initiateBackup(), loadHeader(), restoreFromBackup(), and writeHeader().
SharedSegment Database::pDataSegment [private] |
Definition at line 81 of file Database.h.
Referenced by checkpointImpl(), closeDevices(), closeImpl(), completeBackup(), createDataSegment(), deallocateOldPages(), getDataSegment(), initiateBackup(), recoverPhysical(), restoreFromBackup(), and writeStats().
SharedSegment Database::pTempSegment [private] |
Definition at line 83 of file Database.h.
Referenced by closeDevices(), closeImpl(), createDataSegment(), createTempSegment(), getTempSegment(), and writeStats().
VersionedSegment* Database::pVersionedSegment [private] |
Definition at line 85 of file Database.h.
Referenced by checkpointImpl(), closeDevices(), createDataSegment(), recoverOnline(), recoverPhysical(), and restoreFromBackup().
SharedLogicalTxnLog Database::pTxnLog [private] |
Definition at line 87 of file Database.h.
Referenced by allocateHeader(), checkpointImpl(), closeDevices(), closeImpl(), createTxnLog(), deallocateOldPages(), getTxnLog(), and loadHeader().
PageId Database::headerPageId1 [private] |
Definition at line 89 of file Database.h.
Referenced by allocateHeader(), init(), initiateBackup(), loadHeader(), restoreFromBackup(), and writeHeader().
PageId Database::headerPageId2 [private] |
Definition at line 91 of file Database.h.
Referenced by allocateHeader(), init(), initiateBackup(), loadHeader(), restoreFromBackup(), and writeHeader().
DatabaseHeader Database::header [private] |
Definition at line 93 of file Database.h.
Referenced by allocateHeader(), checkpointImpl(), closeImpl(), createDataSegment(), createShadowLog(), createTxnLog(), getLastCommittedTxnId(), init(), loadHeader(), openSegments(), recover(), recoverOnline(), recoverPhysical(), restoreFromBackup(), and writeHeader().
Definition at line 95 of file Database.h.
bool Database::forceTxns [private] |
Definition at line 97 of file Database.h.
Referenced by areSnapshotsEnabled(), checkpointImpl(), createShadowLog(), createTxnLogSegment(), init(), recoverOnline(), requestCheckpoint(), and shouldForceTxns().
bool Database::disableSnapshots [private] |
bool Database::recoveryRequired [private] |
Definition at line 101 of file Database.h.
Referenced by checkpointImpl(), createDataSegment(), init(), isRecoveryRequired(), prepareForRecovery(), recoverOnline(), and recoverPhysical().
DeviceMode Database::openMode [private] |
Definition at line 103 of file Database.h.
Referenced by createDataDevice(), createDataSegment(), createTempSegment(), Database(), init(), openSegments(), prepareForRecovery(), recover(), and recoverPhysical().
ConfigMap Database::configMap [private] |
Definition at line 105 of file Database.h.
Referenced by getConfigMap(), init(), and readDeviceParams().
Definition at line 109 of file Database.h.
Referenced by cleanupBackupRestore(), closeImpl(), createShadowLog(), createTxnLogSegment(), deallocateOldPages(), getCheckpointThread(), initiateBackup(), openSegments(), and requestCheckpoint().
uint Database::nCheckpointsStat [private] |
Cumulative counter cleared whenever writeStats is called.
Definition at line 116 of file Database.h.
Referenced by checkpointImpl(), init(), and writeStats().
uint Database::nCheckpoints [private] |
Cumulative counter.
Definition at line 121 of file Database.h.
Referenced by checkpointImpl(), init(), requestCheckpoint(), and writeStats().
bool Database::disableDeallocateOld [private] |
If true, ALTER SYSTEM DEALLOCATE OLD is a no-op.
Definition at line 126 of file Database.h.
Referenced by cleanupBackupRestore(), completeBackup(), Database(), deallocateOldPages(), and initiateBackup().
Device used to read and write the backup file during backup and restore.
Definition at line 131 of file Database.h.
Referenced by cleanupBackupRestore(), completeBackup(), initiateBackup(), and restoreFromBackup().
SegmentAccessor Database::scratchAccessor [private] |
Scratch accessor used during backup and restore.
Definition at line 136 of file Database.h.
Referenced by cleanupBackupRestore(), initiateBackup(), and restoreFromBackup().
ParamName Database::paramDatabaseDir [static] |
Definition at line 190 of file Database.h.
Referenced by DatabaseTest::DatabaseTest(), init(), BackupRestoreTest::testBackupCleanup(), BTreeTxnTest::testCaseSetUp(), and BackupRestoreTest::testHeaderBackupRestore().
ParamName Database::paramResourceDir [static] |
ParamName Database::paramForceTxns [static] |
ParamName Database::paramDisableSnapshots [static] |
ParamName Database::paramDatabasePrefix [static] |
ParamName Database::paramTempPrefix [static] |
ParamName Database::paramShadowLogPrefix [static] |
ParamName Database::paramTxnLogPrefix [static] |
ParamName Database::paramInitSizeSuffix [static] |
ParamName Database::paramMaxSizeSuffix [static] |
ParamName Database::paramIncSizeSuffix [static] |
ParamVal Database::valLogAllocLinear [static] |
Definition at line 202 of file Database.h.
ParamVal Database::valLogAllocCircular [static] |
Definition at line 203 of file Database.h.
const SegmentId Database::DEFAULT_DATA_SEGMENT_ID [static] |
const SegmentId Database::TEMP_SEGMENT_ID [static] |
Definition at line 206 of file Database.h.
Referenced by getSegmentById(), ExecStreamFactory::implementSortWithBTree(), and ExecStreamFactory::readBTreeParams().
bool ClosableObject::needsClose [protected, inherited] |
Definition at line 44 of file ClosableObject.h.
Referenced by SegStreamAllocation::beginWrite(), ExecStreamGraphImpl::clear(), ClosableObject::ClosableObject(), ClosableObject::close(), FlatFileBuffer::open(), ExecStreamGraphImpl::open(), ExecStream::open(), and ClosableObject::~ClosableObject().
StrictMutex SynchMonitoredObject::mutex [protected, inherited] |
Definition at line 38 of file SynchMonitoredObject.h.
Referenced by ParallelExecStreamScheduler::abort(), LogicalTxnLog::checkpoint(), checkpointImpl(), CheckpointThread::closeImpl(), LogicalTxnLog::commitTxn(), ParallelExecStreamScheduler::executeManager(), ParallelExecStreamScheduler::executeTask(), LogicalTxnLog::getOldestActiveTxnId(), LogicalTxnLog::newLogicalTxn(), ParallelExecStreamScheduler::readStream(), SXMutex::release(), GroupLock::release(), requestCheckpoint(), CheckpointThread::requestCheckpoint(), LogicalTxnLog::rollbackTxn(), TimerThread::run(), CheckpointThread::run(), ThreadPoolBase::runPooledThread(), SXMutex::setSchedulingPolicy(), TimerThread::signalImmediate(), ParallelExecStreamScheduler::signalSentinel(), ThreadPoolBase::start(), TimerThread::stop(), ThreadPoolBase::stop(), ParallelExecStreamScheduler::stop(), ThreadPool< RandomAccessRequest >::submitTask(), ParallelExecStreamScheduler::tryExecuteManager(), ParallelExecStreamScheduler::tryExecuteTask(), SXMutex::tryUpgrade(), SXMutex::waitFor(), GroupLock::waitFor(), and writeStats().
LocalCondition SynchMonitoredObject::condition [protected, inherited] |
Definition at line 39 of file SynchMonitoredObject.h.
Referenced by ParallelExecStreamScheduler::abort(), checkpointImpl(), CheckpointThread::closeImpl(), LogicalTxnLog::commitTxnWithGroup(), ParallelExecStreamScheduler::executeTask(), ParallelExecStreamScheduler::readStream(), SXMutex::release(), GroupLock::release(), requestCheckpoint(), CheckpointThread::requestCheckpoint(), TimerThread::run(), CheckpointThread::run(), ThreadPoolBase::runPooledThread(), TimerThread::signalImmediate(), TimerThread::stop(), ThreadPoolBase::stop(), ParallelExecStreamScheduler::stop(), ThreadPool< RandomAccessRequest >::submitTask(), ParallelExecStreamScheduler::tryExecuteManager(), ParallelExecStreamScheduler::tryExecuteTask(), SXMutex::waitFor(), and GroupLock::waitFor().