diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-10-22 14:43:51 -0400 |
---|---|---|
committer | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-10-29 18:29:44 -0400 |
commit | 98c2b9e9c05e18c3417dbfd882d7f32b81ec558e (patch) | |
tree | 3de834c7ebee867d12177d541830540002ad28d8 /src/mongo/db/db.cpp | |
parent | 8b07e3e7242c5048eb847105fe30a9e3ef2bb88c (diff) | |
download | mongo-98c2b9e9c05e18c3417dbfd882d7f32b81ec558e.tar.gz |
SERVER-37496 Register balancer shutdown task when MongoD is single-threaded
(cherry picked from commit 871f1234c72f3f390f81dc31fd8a95d8bc69cf91)
Diffstat (limited to 'src/mongo/db/db.cpp')
-rw-r--r-- | src/mongo/db/db.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 0f4e332bc6f..635f13bbd19 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -1267,6 +1267,12 @@ void shutdownTask() { auto const client = Client::getCurrent(); auto const serviceContext = client->getServiceContext(); + // Terminate the balancer thread so it doesn't leak memory. + if (auto balancer = Balancer::get(serviceContext)) { + balancer->interruptBalancer(); + balancer->waitForBalancerToStop(); + } + // Shutdown the TransportLayer so that new connections aren't accepted if (auto tl = serviceContext->getTransportLayer()) { log(LogComponent::kNetwork) << "shutdown: going to close listening sockets..."; |