summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2019-03-14 11:15:07 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2019-03-19 09:28:52 -0400
commitec1e10dc518b36d381faeb228008512f0dee68c4 (patch)
treebddda0da01d35f845c7b3146daae259c1a8d8675 /src/mongo/db
parent7cc0d1c45272b88eb69e2f2d51ae8608fe3ec036 (diff)
downloadmongo-ec1e10dc518b36d381faeb228008512f0dee68c4.tar.gz
SERVER-39221 Test rollback after enableMajorityReadConcern upgrade/downgrade
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/rollback_impl.cpp12
-rw-r--r--src/mongo/db/repl/rollback_test_fixture.h5
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;