summaryrefslogtreecommitdiff
path: root/src/mongo/db/db.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/db.cpp')
-rw-r--r--src/mongo/db/db.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 755bd5997d7..55c15c26593 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -329,10 +329,9 @@ ExitCode _initAndListen(int listenPort) {
// Set up the periodic runner for background job execution. This is required to be running
// before the storage engine is initialized.
auto runner = makePeriodicRunner(serviceContext);
- runner->startup();
serviceContext->setPeriodicRunner(std::move(runner));
FlowControl::set(serviceContext,
- stdx::make_unique<FlowControl>(
+ std::make_unique<FlowControl>(
serviceContext, repl::ReplicationCoordinator::get(serviceContext)));
initializeStorageEngine(serviceContext, StorageEngineInitFlags::kNone);
@@ -617,11 +616,11 @@ ExitCode _initAndListen(int listenPort) {
// Only do this on storage engines supporting snapshot reads, which hold resources we wish to
// release periodically in order to avoid storage cache pressure build up.
if (storageEngine->supportsReadConcernSnapshot()) {
- startPeriodicThreadToAbortExpiredTransactions(serviceContext);
+ PeriodicThreadToAbortExpiredTransactions::get(serviceContext)->start();
// The inMemory engine is not yet used for replica or sharded transactions in production so
// it does not currently maintain snapshot history. It is live in testing, however.
if (!storageEngine->isEphemeral() || getTestCommandsEnabled()) {
- startPeriodicThreadToDecreaseSnapshotHistoryCachePressure(serviceContext);
+ PeriodicThreadToDecreaseSnapshotHistoryIfNotNeeded::get(serviceContext)->start();
}
}
@@ -939,13 +938,12 @@ void shutdownTask(const ShutdownTaskArgs& shutdownArgs) {
flowControlTicketholder->setInShutdown();
}
- // Shut down the background periodic task runner. This must be done before shutting down the
- // storage engine.
- if (auto runner = serviceContext->getPeriodicRunner()) {
- runner->shutdown();
- }
+ if (auto storageEngine = serviceContext->getStorageEngine()) {
+ if (storageEngine->supportsReadConcernSnapshot()) {
+ PeriodicThreadToAbortExpiredTransactions::get(serviceContext)->stop();
+ PeriodicThreadToDecreaseSnapshotHistoryIfNotNeeded::get(serviceContext)->stop();
+ }
- if (serviceContext->getStorageEngine()) {
ServiceContext::UniqueOperationContext uniqueOpCtx;
OperationContext* opCtx = client->getOperationContext();
if (!opCtx) {