summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2016-03-27 19:18:14 -0400
committerScott Hernandez <scotthernandez@gmail.com>2016-03-28 09:33:17 -0400
commit469dd5196c87a1ccb30f4ac1c7d46bd1ca6c113e (patch)
tree3369125de172b88ab18af8d959190927c9c66478
parentbd7ee60bcc37645eb0d0c7d4e9a76909aeb23706 (diff)
downloadmongo-469dd5196c87a1ccb30f4ac1c7d46bd1ca6c113e.tar.gz
SERVER-23010: always wait for snapshot on WriteConcern.Majority
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 1157a7b07fb..1ca21e6a074 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -1343,25 +1343,22 @@ bool ReplicationCoordinatorImpl::_doneWaitingForReplication_inlock(
StringData patternName;
if (writeConcern.wMode == WriteConcernOptions::kMajority) {
- if (useDurableOpTime && _externalState->snapshotsEnabled()) {
- // Make sure we have a valid snapshot.
+ if (_externalState->snapshotsEnabled()) {
+ // Make sure we have a valid "committed" snapshot up to the needed optime.
if (!_currentCommittedSnapshot) {
return false;
}
- if (getWriteConcernMajorityShouldJournal_inlock()) {
- // Wait for the "current" snapshot to advance to/past the opTime.
-
- const auto haveSnapshot = (_currentCommittedSnapshot->opTime >= opTime &&
- _currentCommittedSnapshot->name >= minSnapshot);
- if (!haveSnapshot) {
- log() << "Required snapshot optime: " << opTime << " is not yet part of the "
- << "current snapshot: " << *_currentCommittedSnapshot;
- }
- // We cannot have this committed snapshot until we have replicated to a majority,
- // so we can return true here once that requirement is met for durable writes.
- return haveSnapshot;
+ // Wait for the "current" snapshot to advance to/past the opTime.
+ const auto haveSnapshot = (_currentCommittedSnapshot->opTime >= opTime &&
+ _currentCommittedSnapshot->name >= minSnapshot);
+ if (!haveSnapshot) {
+ LOG(1) << "Required snapshot optime: " << opTime << " is not yet part of the "
+ << "current 'committed' snapshot: " << *_currentCommittedSnapshot;
+ return false;
}
+
+ // Fallthrough to wait for "majority" write concern.
}
// Continue and wait for replication to the majority (of voters).
// *** Needed for J:True, writeConcernMajorityShouldJournal:False (appliedOpTime snapshot).