summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/backports_required_for_multiversion_tests.yml2
-rw-r--r--jstests/replsets/force_shutdown_primary.js7
-rw-r--r--src/mongo/db/commands/shutdown_d.cpp6
3 files changed, 15 insertions, 0 deletions
diff --git a/etc/backports_required_for_multiversion_tests.yml b/etc/backports_required_for_multiversion_tests.yml
index ab3fbb77368..d9b08a98702 100644
--- a/etc/backports_required_for_multiversion_tests.yml
+++ b/etc/backports_required_for_multiversion_tests.yml
@@ -126,6 +126,8 @@ all:
test_file: jstests/core/txns/timestamped_reads_wait_for_prepare_oplog_visibility.js
- ticket: SERVER-53985
test_file: jstests/replsets/unconditional_step_down.js
+ - ticket: SERVER-54366
+ test_file: jstests/replsets/force_shutdown_primary.js
# Tests that should only be excluded from particular suites should be listed under that suite.
suites:
diff --git a/jstests/replsets/force_shutdown_primary.js b/jstests/replsets/force_shutdown_primary.js
index 77e20016de5..2f228df2ac2 100644
--- a/jstests/replsets/force_shutdown_primary.js
+++ b/jstests/replsets/force_shutdown_primary.js
@@ -13,6 +13,7 @@
(function() {
"use strict";
+load("jstests/libs/fail_point_util.js");
load("jstests/libs/write_concern_util.js"); // for stopReplicationOnSecondaries.
const replTest = new ReplSetTest({nodes: 3});
replTest.startSet();
@@ -28,10 +29,16 @@ stopReplicationOnSecondaries(replTest);
jsTestLog("Executing write to primary.");
assert.commandWorked(testDB.foo.insert({x: 2}));
+// To ensure that we kill the shutdown operation during step down, we wait
+// until we hit the 'hangInShutdownBeforeStepdown' failpoint.
+const failPoint = configureFailPoint(primary, 'hangInShutdownBeforeStepdown');
+
jsTestLog("Shutting down primary in a parallel shell");
const shutdownShell = startParallelShell(function() {
db.adminCommand({shutdown: 1, timeoutSecs: 60, force: true});
}, primary.port);
+failPoint.wait();
+failPoint.off();
let shutdownOpID = -1;
let res = {};
diff --git a/src/mongo/db/commands/shutdown_d.cpp b/src/mongo/db/commands/shutdown_d.cpp
index 6dc11a8220a..c4ac2211c9f 100644
--- a/src/mongo/db/commands/shutdown_d.cpp
+++ b/src/mongo/db/commands/shutdown_d.cpp
@@ -42,6 +42,7 @@
namespace mongo {
namespace {
+MONGO_FAIL_POINT_DEFINE(hangInShutdownBeforeStepdown);
MONGO_FAIL_POINT_DEFINE(hangInShutdownAfterStepdown);
} // namespace
@@ -53,6 +54,11 @@ Status stepDownForShutdown(OperationContext* opCtx,
// for any secondaries. Ignore stepdown.
if (replCoord->getConfig().getNumMembers() != 1) {
try {
+ if (MONGO_unlikely(hangInShutdownBeforeStepdown.shouldFail())) {
+ LOGV2(5436600, "hangInShutdownBeforeStepdown failpoint enabled");
+ hangInShutdownBeforeStepdown.pauseWhileSet(opCtx);
+ }
+
// Specify a high freeze time, so that if there is a stall during shut down, the node
// does not run for election.
replCoord->stepDown(opCtx, false /* force */, waitTime, Days(1));