diff options
Diffstat (limited to 'src/mongo/db/db.cpp')
-rw-r--r-- | src/mongo/db/db.cpp | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 4d20f50a16f..4cbafa15ee9 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -62,6 +62,7 @@ #include "mongo/db/clientcursor.h" #include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/commands/feature_compatibility_version_gen.h" +#include "mongo/db/commands/shutdown.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/concurrency/flow_control_ticketholder.h" #include "mongo/db/concurrency/lock_state.h" @@ -928,26 +929,12 @@ void shutdownTask(const ShutdownTaskArgs& shutdownArgs) { opCtx = uniqueOpCtx.get(); } - // 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(); - } - - // Even if the replCoordinator failed to step down, ensure we still shut down the - // TransactionCoordinatorService (see SERVER-45009) - TransactionCoordinatorService::get(serviceContext)->onStepDown(); - } + // For faster tests, we allow a short wait time with setParameter. + auto waitTime = repl::waitForStepDownOnNonCommandShutdown.load() ? Milliseconds(Seconds(10)) + : Milliseconds(100); + const auto forceShutdown = true; + // stepDown should never return an error during force shutdown. + invariant(stepDownForShutdown(opCtx, waitTime, forceShutdown).isOK()); } WaitForMajorityService::get(serviceContext).shutDown(); |