summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2016-02-17 11:07:45 -0500
committerEric Milkie <milkie@10gen.com>2016-02-17 15:40:45 -0500
commit52779c11c025e72a2c22c555bb06e05caf8e1ae1 (patch)
treeeb930db24ab6614098d9fca86327e6ceb6415a34 /src/mongo/db
parentbd2c33b3c6000b92aa42bd285654d8e27bcd3af7 (diff)
downloadmongo-52779c11c025e72a2c22c555bb06e05caf8e1ae1.tar.gz
SERVER-22598 ensure all default write concern options use sync unset
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp4
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.cpp6
-rw-r--r--src/mongo/db/write_concern_options.h3
3 files changed, 9 insertions, 4 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index d7f37369a35..abd758040f0 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -2784,6 +2784,7 @@ TEST_F(ReplCoordTest, AwaitReplicationShouldResolveAsNormalDuringAReconfig) {
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoTimeout;
writeConcern.wNumNodes = 3;
+ writeConcern.syncMode = WriteConcernOptions::SyncMode::NONE;
ReplicationAwaiter awaiter(getReplCoord(), &txn);
awaiter.setOpTime(time);
@@ -2932,6 +2933,7 @@ TEST_F(ReplCoordTest,
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoTimeout;
writeConcern.wMode = WriteConcernOptions::kMajority;
+ writeConcern.syncMode = WriteConcernOptions::SyncMode::NONE;
ReplicationAwaiter awaiter(getReplCoord(), &txn);
awaiter.setOpTime(time);
@@ -2942,6 +2944,8 @@ TEST_F(ReplCoordTest,
WriteConcernOptions writeConcern2;
writeConcern2.wTimeout = WriteConcernOptions::kNoWaiting;
writeConcern2.wMode = WriteConcernOptions::kMajority;
+ writeConcern.syncMode = WriteConcernOptions::SyncMode::NONE;
+
ASSERT_EQUALS(ErrorCodes::WriteConcernFailed,
getReplCoord()->awaitReplication(&txn, time, writeConcern2).status);
diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp
index 2ceb947cb8e..3ea4d8eef42 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.cpp
+++ b/src/mongo/db/repl/replication_coordinator_mock.cpp
@@ -432,7 +432,11 @@ size_t ReplicationCoordinatorMock::getNumUncommittedSnapshots() {
WriteConcernOptions ReplicationCoordinatorMock::populateUnsetWriteConcernOptionsSyncMode(
WriteConcernOptions wc) {
if (wc.syncMode == WriteConcernOptions::SyncMode::UNSET) {
- wc.syncMode = WriteConcernOptions::SyncMode::JOURNAL;
+ if (wc.wMode == WriteConcernOptions::kMajority) {
+ wc.syncMode = WriteConcernOptions::SyncMode::JOURNAL;
+ } else {
+ wc.syncMode = WriteConcernOptions::SyncMode::NONE;
+ }
}
return wc;
}
diff --git a/src/mongo/db/write_concern_options.h b/src/mongo/db/write_concern_options.h
index 91320b0d39a..0c187ed2887 100644
--- a/src/mongo/db/write_concern_options.h
+++ b/src/mongo/db/write_concern_options.h
@@ -51,9 +51,6 @@ public:
WriteConcernOptions() {
reset();
- // We set syncMode to NONE to avoid having an UNSET syncMode in default WriteConcernOptions
- // since that can cause invariants to trigger.
- syncMode = SyncMode::NONE;
}
WriteConcernOptions(int numNodes, SyncMode sync, int timeout);