void DurRecoveryUnit::registerChange(Change* change) { #if ROLLBACK_ENABLED invariant(inAUnitOfWork()); _changes.push_back(ChangePtr(change)); #else change->commit(); delete change; #endif }
void DurRecoveryUnit::endUnitOfWork() { invariant(inAUnitOfWork()); if (haveUncommitedChangesAtCurrentLevel()) { rollbackInnermostChanges(); } _startOfUncommittedChangesForLevel.pop_back(); }
void* DurRecoveryUnit::writingPtr(void* data, size_t len) { invariant(inAUnitOfWork()); if (len == 0) return data; // Don't need to do anything for empty ranges. // Windows requires us to adjust the address space *before* we write to anything. MemoryMappedFile::makeWritable(data, len); registerChange(new MemoryWrite(static_cast<char*>(data), len)); return data; }
void* DurRecoveryUnit::writingPtr(void* data, size_t len) { invariant(inAUnitOfWork()); if (len == 0) return data; // Don't need to do anything for empty ranges. invariant(len < size_t(std::numeric_limits<int>::max())); // Windows requires us to adjust the address space *before* we write to anything. privateViews.makeWritable(data, len); _writes.push_back(Write(static_cast<char*>(data), len, _preimageBuffer.size())); _preimageBuffer.append(static_cast<char*>(data), len); return data; }
void DurRecoveryUnit::publishChanges() { if (!inAUnitOfWork()) return; invariant(!_mustRollback); invariant(inOutermostUnitOfWork()); for (Changes::iterator it = _changes.begin(), end = _changes.end(); it != end; ++it) { (*it)->commit(); } // We now reset to a "clean" state without any uncommited changes. _changes.clear(); invariant(_startOfUncommittedChangesForLevel.front() == 0); }
void* DurRecoveryUnit::writingPtr(void* data, size_t len) { invariant(len > 0); #if ROLLBACK_ENABLED invariant(inAUnitOfWork()); // Windows requires us to adjust the address space *before* we write to anything. MemoryMappedFile::makeWritable(data, len); registerChange(new MemoryWrite(static_cast<char*>(data), len)); return data; #else invariant(_txn->lockState()->isWriteLocked()); return getDur().writingPtr(data, len); #endif }
void DurRecoveryUnit::commitUnitOfWork() { invariant(inAUnitOfWork()); invariant(!_mustRollback); if (!inOutermostUnitOfWork()) { // If we are nested, make all changes for this level part of the containing UnitOfWork. // They will be added to the global damages list once the outermost UnitOfWork commits, // which it must now do. if (haveUncommitedChangesAtCurrentLevel()) { _startOfUncommittedChangesForLevel.back() = _changes.size(); } return; } publishChanges(); // global journal flush opportunity getDur().commitIfNeeded(_txn); }
void DurRecoveryUnit::commitChanges() { if (!inAUnitOfWork()) return; invariant(!_mustRollback); invariant(inOutermostUnitOfWork()); invariant(_startOfUncommittedChangesForLevel.front().changeIndex == 0); invariant(_startOfUncommittedChangesForLevel.front().writeIndex == 0); if (getDur().isDurable()) pushChangesToDurSubSystem(); for (Changes::const_iterator it = _changes.begin(), end = _changes.end(); it != end; ++it) { (*it)->commit(); } // We now reset to a "clean" state without any uncommited changes. _changes.clear(); _writes.clear(); _preimageBuffer.clear(); }
void DurRecoveryUnit::commitAndRestart() { invariant( !inAUnitOfWork() ); // no-op since we have no transaction }
void DurRecoveryUnit::registerChange(Change* change) { invariant(inAUnitOfWork()); _changes.push_back(ChangePtr(change)); }
bool DurRecoveryUnit::awaitCommit() { invariant(!inAUnitOfWork()); return getDur().awaitCommit(); }
bool DurRecoveryUnit::awaitCommit() { #if ROLLBACK_ENABLED invariant(!inAUnitOfWork()); #endif return getDur().awaitCommit(); }