diff options
author | Judah Schvimer <judah@mongodb.com> | 2018-05-21 18:52:55 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2018-05-21 18:52:55 -0400 |
commit | 4cee07d8a97bb0663e7bfbc3f2e1fbf539140adf (patch) | |
tree | 18572886d8e6c0b3f0f11012b61ad1576b20ace0 /src | |
parent | 6ab1592260c9b21d802aa65a11d268c0a97b11a7 (diff) | |
download | mongo-7f0065e08c5170d85b20f86a9f72479c8ac60baa.tar.gz |
SERVER-35113 Allow single voting primaries to advance stable timestamp even when last applied does not advancer4.0.0-rc0
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 5 |
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(); } } |