summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorWilliam Schultz <william.schultz@mongodb.com>2020-04-13 23:36:31 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-14 03:57:38 +0000
commit26dbfa6c56ce5a4b80e1f57c906213956f8a2eff (patch)
tree2d4f2c3cd7c5a6fafda570ee6d062e6fe6a766d2 /jstests
parent2b742ad3d0fbf0238c32e6cd3b5842fb5bee77b9 (diff)
downloadmongo-26dbfa6c56ce5a4b80e1f57c906213956f8a2eff.tar.gz
SERVER-47119 Revert SERVER-46571
This reverts commit a2eeeedb3e358f9a71042a2ff752b67844d4dcf7.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/awaitable_ismaster_stepdown_stepup.js45
1 files changed, 39 insertions, 6 deletions
diff --git a/jstests/replsets/awaitable_ismaster_stepdown_stepup.js b/jstests/replsets/awaitable_ismaster_stepdown_stepup.js
index c034db62aac..22235617344 100644
--- a/jstests/replsets/awaitable_ismaster_stepdown_stepup.js
+++ b/jstests/replsets/awaitable_ismaster_stepdown_stepup.js
@@ -68,15 +68,29 @@ function runAwaitableIsMasterBeforeStepUp(topologyVersionField) {
assert.hasFields(resAfterEnteringDrainMode, ["primary"]);
// The TopologyVersion from resAfterEnteringDrainMode should now be stale since we expect
- // the primary to exit drain mode and increment the counter once again.
- const resAfterExitingDrainMode = assert.commandWorked(db.runCommand({
+ // the primary to increase the config term and increment the counter once again.
+ const resAfterReconfigOnStepUp = assert.commandWorked(db.runCommand({
isMaster: 1,
topologyVersion: resAfterEnteringDrainMode.topologyVersion,
maxAwaitTimeMS: 99999999,
}));
assert.eq(resAfterEnteringDrainMode.topologyVersion.counter + 1,
- resAfterExitingDrainMode.topologyVersion.counter,
- resAfterExitingDrainMode);
+ resAfterReconfigOnStepUp.topologyVersion.counter,
+ resAfterReconfigOnStepUp);
+ assert.eq(false, resAfterReconfigOnStepUp.ismaster, resAfterReconfigOnStepUp);
+ assert.eq(true, resAfterReconfigOnStepUp.secondary, resAfterReconfigOnStepUp);
+ assert.hasFields(resAfterReconfigOnStepUp, ["primary"]);
+}
+
+function runAwaitableIsMasterAfterStepUp(topologyVersionField) {
+ // The TopologyVersion from resAfterReconfigOnStepUp should now be stale since we expect
+ // the primary to exit drain mode and increment the counter once again.
+ const resAfterExitingDrainMode = assert.commandWorked(db.runCommand({
+ isMaster: 1,
+ topologyVersion: topologyVersionField,
+ maxAwaitTimeMS: 99999999,
+ }));
+ assert.eq(topologyVersionField.counter + 1, resAfterExitingDrainMode.topologyVersion.counter);
assert.eq(true, resAfterExitingDrainMode.ismaster, resAfterExitingDrainMode);
assert.eq(false, resAfterExitingDrainMode.secondary, resAfterExitingDrainMode);
assert.hasFields(resAfterExitingDrainMode, ["primary"]);
@@ -97,12 +111,13 @@ failPoint.wait();
assert.commandWorked(db.adminCommand({replSetStepDown: 60, force: true}));
awaitIsMasterBeforeStepDown();
-const response = assert.commandWorked(node.getDB(dbName).runCommand({isMaster: 1}));
+let response = assert.commandWorked(node.getDB(dbName).runCommand({isMaster: 1}));
assert(response.hasOwnProperty("topologyVersion"), tojson(res));
const topologyVersionAfterStepDown = response.topologyVersion;
// Reconfigure the failpoint to refresh the number of times the failpoint has been entered.
failPoint = configureFailPoint(node, "waitForIsMasterResponse");
+const hangFailPoint = configureFailPoint(node, "hangAfterReconfigOnDrainComplete");
// Send an awaitable isMaster request. This will block until maxAwaitTimeMS has elapsed or a
// topology change happens.
let awaitIsMasterBeforeStepUp = startParallelShell(
@@ -111,7 +126,25 @@ failPoint.wait();
// Unfreezing the old primary will cause the node to step up in a single node replica set.
assert.commandWorked(node.adminCommand({replSetFreeze: 0}));
+
+// Wait until stepup thread hangs after the reconfig.
+hangFailPoint.wait();
awaitIsMasterBeforeStepUp();
+response = assert.commandWorked(node.getDB(dbName).runCommand({isMaster: 1}));
+assert(response.hasOwnProperty("topologyVersion"), tojson(res));
+const topologyVersionAfterStepUp = response.topologyVersion;
+
+// Reconfigure the failpoint to refresh the number of times the failpoint has been entered.
+failPoint = configureFailPoint(node, "waitForIsMasterResponse");
+// Send an awaitable isMaster request. This will block until maxAwaitTimeMS has elapsed or a
+// topology change happens.
+let awaitIsMasterAfterStepUp = startParallelShell(
+ funWithArgs(runAwaitableIsMasterAfterStepUp, topologyVersionAfterStepUp), node.port);
+failPoint.wait();
+// Let the stepup thread to continue.
+hangFailPoint.off();
+awaitIsMasterAfterStepUp();
+
replTest.stopSet();
-})(); \ No newline at end of file
+})();