summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2020-06-11 18:06:03 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-24 23:37:35 +0000
commitf8e35f0b44a14051eae4abb61115b106f7cc3e2a (patch)
tree5138b970e04e8f9eff995c078eb73687bd492ae9
parent46579d22c2ee61185efdf334f16cfc453e17b65c (diff)
downloadmongo-f8e35f0b44a14051eae4abb61115b106f7cc3e2a.tar.gz
SERVER-48712 Race in write_concern_after_stepdown.js
(cherry picked from commit 351ec9947164cd78c8f003e972ba5d71f6438b53)
-rw-r--r--jstests/replsets/write_concern_after_stepdown.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/jstests/replsets/write_concern_after_stepdown.js b/jstests/replsets/write_concern_after_stepdown.js
index b54e62e8965..21185a51097 100644
--- a/jstests/replsets/write_concern_after_stepdown.js
+++ b/jstests/replsets/write_concern_after_stepdown.js
@@ -5,8 +5,9 @@
(function() {
'use strict';
-load("jstests/replsets/rslib.js");
+load("jstests/libs/fail_point_util.js");
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/rslib.js");
var name = "writeConcernStepDownAndBackUp";
var dbName = "wMajorityCheck";
@@ -42,6 +43,9 @@ assert.writeOK(nodes[0].getDB(dbName).getCollection(collName).insert(
// Stop the secondaries from replicating.
stopServerReplication(secondaries);
+// Stop the primary from calling into awaitReplication().
+const hangBeforeWaitingForWriteConcern =
+ configureFailPoint(nodes[0], "hangBeforeWaitingForWriteConcern");
// Stop the primary from being able to complete stepping down.
assert.commandWorked(
nodes[0].adminCommand({configureFailPoint: 'blockHeartbeatStepdown', mode: 'alwaysOn'}));
@@ -53,14 +57,18 @@ var doMajorityWrite = function() {
// the error returned by the write concern failure.
assert.commandWorked(db.adminCommand({ismaster: 1, hangUpOnStepDown: false}));
+ jsTestLog("Begin waiting for w:majority write");
var res = db.getSiblingDB('wMajorityCheck').stepdownAndBackUp.insert({a: 2}, {
writeConcern: {w: 'majority', wtimeout: 600000}
});
+ jsTestLog(`w:majority write replied: ${tojson(res)}`);
assert.writeErrorWithCode(
res, [ErrorCodes.PrimarySteppedDown, ErrorCodes.InterruptedDueToReplStateChange]);
};
var joinMajorityWriter = startParallelShell(doMajorityWrite, nodes[0].port);
+// Ensure the parallel shell hangs on the majority write before stepping the primary down.
+hangBeforeWaitingForWriteConcern.wait();
jsTest.log("Disconnect primary from all secondaries");
nodes[0].disconnect(nodes[1]);
@@ -91,6 +99,10 @@ nodes[2].acceptConnectionsFrom(nodes[0]);
assert.commandWorked(
nodes[0].adminCommand({configureFailPoint: 'blockHeartbeatStepdown', mode: 'off'}));
+jsTestLog("Unblock the thread waiting for replication of the now rolled-back write, ensure " +
+ "that the write concern failed");
+hangBeforeWaitingForWriteConcern.off();
+
joinMajorityWriter();
// Node 0 will go into rollback after it steps down. We want to wait for that to happen, and