diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-06-04 18:17:42 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-06-04 18:17:42 -0400 |
commit | 64e3b85a7c8a4a6ea7c68f25ae27780c702cdfb5 (patch) | |
tree | 0143c273b63cfd4850d6f69cbd222ea3dec64d9d /src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp | |
parent | b0e11bb814f6554dfc791ba5a05e007f4d1efec9 (diff) | |
download | mongo-64e3b85a7c8a4a6ea7c68f25ae27780c702cdfb5.tar.gz |
Revert "SERVER-13951 First phase of rollback implementation"
Broke Windows Compile
This reverts commit 8b0d5c879339e16f06829ebb4265e54b1a356b2a.
Diffstat (limited to 'src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp')
-rw-r--r-- | src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp | 110 |
1 files changed, 4 insertions, 106 deletions
diff --git a/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp b/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp index c0970763eb4..20f61fd1c3e 100644 --- a/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp @@ -30,111 +30,17 @@ #include "mongo/db/storage/mmap_v1/dur.h" -// Remove once we are ready to enable -#define ROLLBACK_ENABLED false - namespace mongo { DurRecoveryUnit::DurRecoveryUnit() { _hasWrittenSinceCheckpoint = false; } - void DurRecoveryUnit::beginUnitOfWork() { -#if ROLLBACK_ENABLED - _nestingLevel++; -#endif - } - - void DurRecoveryUnit::commitUnitOfWork() { -#if ROLLBACK_ENABLED - invariant(_state != MUST_ROLLBACK); - invariant(_nestingLevel > 0); - - if (_nestingLevel != 1) { - // If we are nested, punt to outer UnitOfWork. These changes will only be pushed to the - // global damages list when the outer UnitOfWork commits (which it must now do). - if (haveUncommitedChanges()) - _state = MUST_COMMIT; - return; - } - - publishChanges(); -#endif - - // global journal flush - getDur().commitIfNeeded(); - } - - void DurRecoveryUnit::endUnitOfWork() { -#if ROLLBACK_ENABLED - invariant(_nestingLevel > 0); - - if (--_nestingLevel != 0) { - // If we are nested, punt to outer UnitOfWork. These changes will only be rolled back - // when the outer UnitOfWork rolls back (which it must now do). - if (haveUncommitedChanges()) { - invariant(_state != MUST_COMMIT); - _state = MUST_ROLLBACK; - } - return; - } - - rollbackChanges(); -#endif - } - - void DurRecoveryUnit::publishChanges() { - invariant(_state != MUST_ROLLBACK); - - if (getDur().isDurable()) { - for (Changes::iterator it=_changes.begin(), end=_changes.end(); it != end; ++it) { - // TODO don't go through getDur() interface. - getDur().writingPtr(it->base, it->preimage.size()); - } - } - - reset(); - } - - void DurRecoveryUnit::rollbackChanges() { - invariant(_state != MUST_COMMIT); - - for (Changes::reverse_iterator it=_changes.rbegin(), end=_changes.rend(); it != end; ++it) { - // TODO need to add these pages to our "dirty count" somehow. - it->preimage.copy(it->base, it->preimage.size()); - } - - reset(); - } - - void DurRecoveryUnit::recordPreimage(char* data, size_t len) { - invariant(len > 0); - - Change change; - change.base = data; - change.preimage.assign(data, len); - _changes.push_back(change); - } - - void DurRecoveryUnit::reset() { - _state = NORMAL; - _changes.clear(); - } - bool DurRecoveryUnit::awaitCommit() { -#if ROLLBACK_ENABLED - invariant(_state != MUST_ROLLBACK); - publishChanges(); - _state = NORMAL; -#endif return getDur().awaitCommit(); } bool DurRecoveryUnit::commitIfNeeded(bool force) { -#if ROLLBACK_ENABLED - invariant(_state != MUST_ROLLBACK); - publishChanges(); -#endif _hasWrittenSinceCheckpoint = false; return getDur().commitIfNeeded(force); } @@ -144,23 +50,15 @@ namespace mongo { } void* DurRecoveryUnit::writingPtr(void* data, size_t len) { -#if ROLLBACK_ENABLED - invariant(_nestingLevel >= 1); - invariant(_state != MUST_ROLLBACK); - recordPreimage(static_cast<char*>(data), len); - _hasWrittenSinceCheckpoint = true; - return data; -#else _hasWrittenSinceCheckpoint = true; return getDur().writingPtr(data, len); -#endif + } + + void DurRecoveryUnit::createdFile(const std::string& filename, unsigned long long len) { + getDur().createdFile(filename, len); } void DurRecoveryUnit::syncDataAndTruncateJournal() { -#if ROLLBACK_ENABLED - invariant(_state != MUST_ROLLBACK); - publishChanges(); -#endif return getDur().syncDataAndTruncateJournal(); } |