summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2018-05-21 18:52:55 -0400
committerSpencer T Brody <spencer@mongodb.com>2018-05-21 18:52:55 -0400
commit4cee07d8a97bb0663e7bfbc3f2e1fbf539140adf (patch)
tree18572886d8e6c0b3f0f11012b61ad1576b20ace0 /src/mongo/db
parent6ab1592260c9b21d802aa65a11d268c0a97b11a7 (diff)
downloadmongo-4cee07d8a97bb0663e7bfbc3f2e1fbf539140adf.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/mongo/db')
-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();
}
}