summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmirsaman Memaripour <amirsaman.memaripour@mongodb.com>2020-04-02 11:54:31 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-03 18:38:41 +0000
commit6db809e1d0cbfac3dcaf95b50f2e4bf4c97b4e1e (patch)
tree160ca36db2d3d25fb214a725ccb970875dce4360
parent420d27bb0e5c3c6a66a2a639e19a0b604dd1074d (diff)
downloadmongo-6db809e1d0cbfac3dcaf95b50f2e4bf4c97b4e1e.tar.gz
SERVER-46534 Make notMasterUnacknowledgedWrites ignore reads
(cherry picked from commit 519908a1925e17fcf9e24d90d3b5e67b4d4c7086)
-rw-r--r--buildscripts/resmokeconfig/suites/replica_sets.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/replica_sets_auth.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/replica_sets_ese.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/replica_sets_ese_gcm.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/replica_sets_large_txns_format.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/replica_sets_max_mirroring.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/replica_sets_multiversion.yml2
-rw-r--r--jstests/replsets/not_master_unacknowledged_write.js13
-rw-r--r--src/mongo/db/service_entry_point_common.cpp5
9 files changed, 16 insertions, 16 deletions
diff --git a/buildscripts/resmokeconfig/suites/replica_sets.yml b/buildscripts/resmokeconfig/suites/replica_sets.yml
index c82320b21cb..dbcb0f3c5c8 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets.yml
@@ -4,8 +4,6 @@ selector:
roots:
- jstests/replsets/*.js
exclude_files:
- # TODO SERVER-46534 will make this work with mirrored reads on
- - jstests/replsets/read_operations_during_step_up.js
executor:
config:
diff --git a/buildscripts/resmokeconfig/suites/replica_sets_auth.yml b/buildscripts/resmokeconfig/suites/replica_sets_auth.yml
index f665ef24361..904256d3302 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_auth.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_auth.yml
@@ -15,8 +15,6 @@ selector:
- jstests/replsets/interrupted_batch_insert.js
- jstests/replsets/transactions_reaped_with_tickets_exhausted.js
- jstests/replsets/transactions_committed_with_tickets_exhausted.js
- # TODO SERVER-46534 will make this work with mirrored reads on
- - jstests/replsets/read_operations_during_step_up.js
executor:
config:
diff --git a/buildscripts/resmokeconfig/suites/replica_sets_ese.yml b/buildscripts/resmokeconfig/suites/replica_sets_ese.yml
index d235e1c4855..7142fd7d1cd 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_ese.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_ese.yml
@@ -8,8 +8,6 @@ selector:
roots:
- jstests/replsets/*.js
exclude_files:
- # TODO SERVER-46534 will make this work with mirrored reads on
- - jstests/replsets/read_operations_during_step_up.js
executor:
config:
diff --git a/buildscripts/resmokeconfig/suites/replica_sets_ese_gcm.yml b/buildscripts/resmokeconfig/suites/replica_sets_ese_gcm.yml
index 44cf18ede6b..012e539b648 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_ese_gcm.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_ese_gcm.yml
@@ -8,8 +8,6 @@ selector:
roots:
- jstests/replsets/*.js
exclude_files:
- # TODO SERVER-46534 will make this work with mirrored reads on
- - jstests/replsets/read_operations_during_step_up.js
executor:
config:
diff --git a/buildscripts/resmokeconfig/suites/replica_sets_large_txns_format.yml b/buildscripts/resmokeconfig/suites/replica_sets_large_txns_format.yml
index 1ba68580e65..eaa598ec243 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_large_txns_format.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_large_txns_format.yml
@@ -7,8 +7,6 @@ selector:
# Transactions are not allowed to operate on capped collections.
- requires_capped
exclude_files:
- # TODO SERVER-46534 will make this work with mirrored reads on
- - jstests/replsets/read_operations_during_step_up.js
executor:
config:
diff --git a/buildscripts/resmokeconfig/suites/replica_sets_max_mirroring.yml b/buildscripts/resmokeconfig/suites/replica_sets_max_mirroring.yml
index 4c0d764a305..c4484189587 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_max_mirroring.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_max_mirroring.yml
@@ -4,8 +4,6 @@ selector:
roots:
- jstests/replsets/*.js
exclude_files:
- # TODO SERVER-46534 will make this work with mirrored reads on
- - jstests/replsets/read_operations_during_step_up.js
executor:
config:
diff --git a/buildscripts/resmokeconfig/suites/replica_sets_multiversion.yml b/buildscripts/resmokeconfig/suites/replica_sets_multiversion.yml
index 238e8aa2fab..912c5cf419a 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_multiversion.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_multiversion.yml
@@ -7,8 +7,6 @@ selector:
- multiversion_incompatible
- requires_fcv_44
exclude_files:
- # TODO SERVER-46534 will make this work with mirrored reads on
- - jstests/replsets/read_operations_during_step_up.js
executor:
config:
shell_options:
diff --git a/jstests/replsets/not_master_unacknowledged_write.js b/jstests/replsets/not_master_unacknowledged_write.js
index 087361c8bc3..a1570de931a 100644
--- a/jstests/replsets/not_master_unacknowledged_write.js
+++ b/jstests/replsets/not_master_unacknowledged_write.js
@@ -22,6 +22,19 @@ var secondaryDB = secondary.getDB("test");
var primaryColl = primaryDB[collName];
var secondaryColl = secondaryDB[collName];
+// Verify that reading from secondaries does not impact `notMasterUnacknowledgedWrites`.
+const preReadingCounter = getNotMasterUnackWritesCounter();
+jsTestLog("Reading from secondary ...");
+[{name: "findOne", fn: () => secondaryColl.findOne()},
+ {name: "distinct", fn: () => secondaryColl.distinct("item")},
+ {name: "count", fn: () => secondaryColl.find().count()},
+].map(({name, fn}) => {
+ assert.doesNotThrow(fn);
+ assert.eq(assert.commandWorked(secondary.getDB("admin").isMaster()).ismaster, false);
+});
+const postReadingCounter = getNotMasterUnackWritesCounter();
+assert.eq(preReadingCounter, postReadingCounter);
+
jsTestLog("Primary on port " + primary.port + " hangs up on unacknowledged writes");
// Do each write method with unacknowledged write concern, "wc".
[{name: "insertOne", fn: (wc) => secondaryColl.insertOne({}, wc)},
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 3f1914537e0..a80fb8fa87f 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -1281,6 +1281,7 @@ DbResponse receivedCommands(OperationContext* opCtx,
const ServiceEntryPointCommon::Hooks& behaviors) {
auto replyBuilder = rpc::makeReplyBuilder(rpc::protocolForMessage(message));
OpMsgRequest request;
+ Command* c = nullptr;
[&] {
try { // Parse.
request = rpc::opMsgRequestFromAnyProtocol(message);
@@ -1311,7 +1312,6 @@ DbResponse receivedCommands(OperationContext* opCtx,
try { // Execute.
curOpCommandSetup(opCtx, request);
- Command* c = nullptr;
// In the absence of a Command object, no redaction is possible. Therefore
// to avoid displaying potentially sensitive information in the logs,
// we restrict the log message to the name of the unrecognized command.
@@ -1373,7 +1373,8 @@ DbResponse receivedCommands(OperationContext* opCtx,
if (OpMsg::isFlagSet(message, OpMsg::kMoreToCome)) {
// Close the connection to get client to go through server selection again.
if (LastError::get(opCtx->getClient()).hadNotMasterError()) {
- notMasterUnackWrites.increment();
+ if (c && c->getReadWriteType() == Command::ReadWriteType::kWrite)
+ notMasterUnackWrites.increment();
uasserted(ErrorCodes::NotMaster,
str::stream()
<< "Not-master error while processing '" << request.getCommandName()