summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/oplog.cpp11
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp5
2 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index bbeebdc85f9..d50da9506d1 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -111,6 +111,9 @@ using IndexVersion = IndexDescriptor::IndexVersion;
namespace repl {
namespace {
+
+MONGO_FP_DECLARE(sleepBetweenInsertOpTimeGenerationAndLogOp);
+
/**
* The `_localOplogCollection` pointer is always valid (or null) because an
* operation must take the global exclusive lock to set the pointer to null when
@@ -526,6 +529,14 @@ std::vector<OpTime> logInsertOps(OperationContext* opCtx,
opTimes.push_back(insertStatementOplogSlot.opTime);
}
+ MONGO_FAIL_POINT_BLOCK(sleepBetweenInsertOpTimeGenerationAndLogOp, customWait) {
+ const BSONObj& data = customWait.getData();
+ auto numMillis = data["waitForMillis"].numberInt();
+ log() << "Sleeping for " << numMillis << "ms after receiving " << count << " optimes from "
+ << opTimes.front() << " to " << opTimes.back();
+ sleepmillis(numMillis);
+ }
+
std::unique_ptr<DocWriter const* []> basePtrs(new DocWriter const*[count]);
for (size_t i = 0; i < count; i++) {
basePtrs[i] = &writers[i];
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 88d3e717419..d16dfcaa613 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -1046,6 +1046,11 @@ void ReplicationCoordinatorImpl::setMyLastAppliedOpTimeForward(const OpTime& opT
if (opTime > _getMyLastAppliedOpTime_inlock()) {
_setMyLastAppliedOpTime_inlock(opTime, false, consistency);
_reportUpstream_inlock(std::move(lock));
+ } else if (consistency == DataConsistency::Consistent && _canAcceptNonLocalWrites &&
+ _rsConfig.getWriteMajority() == 1) {
+ // Single vote primaries may have a lagged stable timestamp due to paring back the stable
+ // timestamp to the all committed timestamp.
+ _setStableTimestampForStorage_inlock();
}
}