summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@mongodb.com>2019-09-09 17:12:28 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-31 15:34:47 +0000
commit226949cc252af265483afbf859b446590b09b098 (patch)
tree06f6fe06e7b6a73222de245e945cc0bdca606630
parenta411d4c1c47a2ec38bcc856007538695c0fcc2a9 (diff)
downloadmongo-226949cc252af265483afbf859b446590b09b098.tar.gz
SERVER-42525 Single-node replica sets shouldn't wait for electable caught up secondaries during shutdown
(cherry picked from commit 2c3e8294acf82fff975a620b5fc45778c6ef2a45)
-rw-r--r--src/mongo/db/db.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 594e4ba654d..76908ece66a 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -1292,19 +1292,24 @@ void shutdownTask(const ShutdownTaskArgs& shutdownArgs) {
opCtx = uniqueOpCtx.get();
}
- try {
- // For faster tests, we allow a short wait time with setParameter.
- auto waitTime = waitForStepDownOnNonCommandShutdown.load()
- ? Milliseconds(Seconds(10))
- : Milliseconds(100);
-
- uassertStatusOK(
- replCoord->stepDown(opCtx, false /* force */, waitTime, Seconds(120)));
- } catch (const ExceptionFor<ErrorCodes::NotMaster>&) {
- // ignore not master errors
- } catch (const DBException& e) {
- log() << "Failed to stepDown in non-command initiated shutdown path "
- << e.toString();
+ // If this is a single node replica set, then we don't have to wait
+ // for any secondaries. Ignore stepdown.
+ if (repl::ReplicationCoordinator::get(serviceContext)->getConfig().getNumMembers() !=
+ 1) {
+ try {
+ // For faster tests, we allow a short wait time with setParameter.
+ auto waitTime = waitForStepDownOnNonCommandShutdown.load()
+ ? Milliseconds(Seconds(10))
+ : Milliseconds(100);
+
+ uassertStatusOK(
+ replCoord->stepDown(opCtx, false /* force */, waitTime, Seconds(120)));
+ } catch (const ExceptionFor<ErrorCodes::NotMaster>&) {
+ // ignore not master errors
+ } catch (const DBException& e) {
+ log() << "Failed to stepDown in non-command initiated shutdown path "
+ << e.toString();
+ }
}
}
}