diff options
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.cpp | 15 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index ed9a5753956..5537f73eb1d 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -112,7 +112,6 @@ namespace mongo { namespace repl { MONGO_FAIL_POINT_DEFINE(stepdownHangBeforePerformingPostMemberStateUpdateActions); -MONGO_FAIL_POINT_DEFINE(holdStableTimestampAtSpecificTimestamp); MONGO_FAIL_POINT_DEFINE(stepdownHangBeforeRSTLEnqueue); // Fail setMaintenanceMode with ErrorCodes::NotSecondary to simulate a concurrent election. MONGO_FAIL_POINT_DEFINE(setMaintenanceModeFailsWithNotSecondary); @@ -4859,11 +4858,6 @@ boost::optional<OpTimeAndWallTime> ReplicationCoordinatorImpl::_chooseStableOpTi maximumStableOpTime.opTime.getTimestamp()); } - holdStableTimestampAtSpecificTimestamp.execute([&](const BSONObj& dataObj) { - const auto holdStableTimestamp = dataObj["timestamp"].timestamp(); - maximumStableTimestamp = std::min(maximumStableTimestamp, holdStableTimestamp); - }); - maximumStableOpTime = {OpTime(maximumStableTimestamp, maximumStableOpTime.opTime.getTerm()), maximumStableOpTime.wallTime}; diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index 47c0a5a7190..07e1b21ea33 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -85,6 +85,8 @@ namespace mongo { namespace repl { +MONGO_FAIL_POINT_DEFINE(holdStableTimestampAtSpecificTimestamp); + const char StorageInterfaceImpl::kDefaultRollbackIdNamespace[] = "local.system.rollback.id"; const char StorageInterfaceImpl::kRollbackIdFieldName[] = "rollbackId"; const char StorageInterfaceImpl::kRollbackIdDocumentId[] = "rollbackId"; @@ -1228,7 +1230,18 @@ StatusWith<OptionalCollectionUUID> StorageInterfaceImpl::getCollectionUUID( } void StorageInterfaceImpl::setStableTimestamp(ServiceContext* serviceCtx, Timestamp snapshotName) { - serviceCtx->getStorageEngine()->setStableTimestamp(snapshotName); + auto newStableTimestamp = snapshotName; + // Hold the stable timestamp back if this failpoint is enabled. + holdStableTimestampAtSpecificTimestamp.execute([&](const BSONObj& dataObj) { + const auto holdStableTimestamp = dataObj["timestamp"].timestamp(); + if (newStableTimestamp > holdStableTimestamp) { + newStableTimestamp = holdStableTimestamp; + LOGV2(4784410, + "holdStableTimestampAtSpecificTimestamp holding the stable timestamp", + "holdStableTimestamp"_attr = holdStableTimestamp); + } + }); + serviceCtx->getStorageEngine()->setStableTimestamp(newStableTimestamp); } void StorageInterfaceImpl::setInitialDataTimestamp(ServiceContext* serviceCtx, |