diff options
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/rollback_impl.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/repl/rollback_test_fixture.h | 5 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp index f8092ab3896..b2d29a6be00 100644 --- a/src/mongo/db/repl/rollback_impl.cpp +++ b/src/mongo/db/repl/rollback_impl.cpp @@ -810,6 +810,8 @@ StatusWith<RollBackLocalOperations::RollbackCommonPoint> RollbackImpl::_findComm OpTime commonPointOpTime = commonPointSW.getValue().getOpTime(); OpTime lastCommittedOpTime = _replicationCoordinator->getLastCommittedOpTime(); OpTime committedSnapshot = _replicationCoordinator->getCurrentCommittedSnapshotOpTime(); + auto stableTimestamp = + _storageInterface->getLastStableRecoveryTimestamp(opCtx->getServiceContext()); log() << "Rollback common point is " << commonPointOpTime; @@ -821,6 +823,16 @@ StatusWith<RollBackLocalOperations::RollbackCommonPoint> RollbackImpl::_findComm invariant(commonPointOpTime.getTimestamp() >= committedSnapshot.getTimestamp()); invariant(commonPointOpTime >= committedSnapshot); + // Rollback common point should be >= the stable timestamp. + invariant(stableTimestamp); + if (commonPointOpTime.getTimestamp() < *stableTimestamp) { + // This is an fassert rather than an invariant, since it can happen if the server was + // recently upgraded to enableMajorityReadConcern=true. + severe() << "Common point must be at least stable timestamp, common point: " + << commonPointOpTime.getTimestamp() << ", stable timestamp: " << *stableTimestamp; + fassertFailedNoTrace(51121); + } + return commonPointSW.getValue(); } diff --git a/src/mongo/db/repl/rollback_test_fixture.h b/src/mongo/db/repl/rollback_test_fixture.h index 48fc833f9cf..4424ef7b1fe 100644 --- a/src/mongo/db/repl/rollback_test_fixture.h +++ b/src/mongo/db/repl/rollback_test_fixture.h @@ -146,6 +146,11 @@ public: return true; } + boost::optional<Timestamp> getLastStableRecoveryTimestamp( + ServiceContext* serviceCtx) const override { + return _stableTimestamp; + } + void setRecoverToTimestampStatus(Status status) { stdx::lock_guard<stdx::mutex> lock(_mutex); _recoverToTimestampStatus = status; |