summaryrefslogtreecommitdiff
path: root/src/mongo/db/db.cpp
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@mongodb.com>2019-09-09 17:12:28 +0000
committerevergreen <evergreen@mongodb.com>2019-09-09 17:12:28 +0000
commit2c3e8294acf82fff975a620b5fc45778c6ef2a45 (patch)
tree3d402533aa486d7a05f465fc6af92ea27ec2df2e /src/mongo/db/db.cpp
parent2947c796a6ed3ce61d4420744feec10c2cff6fde (diff)
downloadmongo-2c3e8294acf82fff975a620b5fc45778c6ef2a45.tar.gz
SERVER-42525 Single-node replica sets shouldn't wait for electable caught up secondaries during shutdown
Diffstat (limited to 'src/mongo/db/db.cpp')
-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 b9025bd8cce..1f76b6e6d03 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -894,17 +894,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();
+ }
}
}