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
commit8991b234b8c6b56e663bb7c2a996de380442698c (patch)
tree9d147ef839b315d04986f0166abbcc85b1638685
parent2d731cc96b0d09deaf4fbd20356f7901d4e70c4e (diff)
downloadmongo-8991b234b8c6b56e663bb7c2a996de380442698c.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 ba90c613d60..ef2b9a220ac 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -904,19 +904,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();
+ }
}
}
}