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-04-09 13:02:36 +0000
commite3abfc3a47e1d76952d3ff4e3477b3f0440e5d3a (patch)
treebcdb19ede2cc243bc526ca47e5b280b39c5a0b03
parentc6a6e086082e42e6cbb4fe466e75a883714df877 (diff)
downloadmongo-e3abfc3a47e1d76952d3ff4e3477b3f0440e5d3a.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.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index b9d847adede..788fda46b59 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -919,17 +919,21 @@ void shutdownTask(const ShutdownTaskArgs& shutdownArgs) {
opCtx = uniqueOpCtx.get();
}
- try {
- // For faster tests, we allow a short wait time with setParameter.
- auto waitTime = repl::waitForStepDownOnNonCommandShutdown.load()
- ? Milliseconds(Seconds(10))
- : Milliseconds(100);
-
- 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 = repl::waitForStepDownOnNonCommandShutdown.load()
+ ? Milliseconds(Seconds(10))
+ : Milliseconds(100);
+ 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();
+ }
}
}