diff options
author | Jiawei Yang <jiawei.yang@mongodb.com> | 2023-03-01 23:17:01 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-03-13 22:47:43 +0000 |
commit | 9f2867c9da77e2d64df3852f7d4578f10e6f0817 (patch) | |
tree | 3c7ec7b6871d181abb49663e80a6ce97e248c383 /src/mongo/db/storage | |
parent | a8be7ac8d8d9c41694e5d34d54b3050ee06f6589 (diff) | |
download | mongo-9f2867c9da77e2d64df3852f7d4578f10e6f0817.tar.gz |
SERVER-70127 change system operation threads to be killable by default
Diffstat (limited to 'src/mongo/db/storage')
5 files changed, 18 insertions, 7 deletions
diff --git a/src/mongo/db/storage/checkpointer.cpp b/src/mongo/db/storage/checkpointer.cpp index 7eecdcfad61..3a585497b52 100644 --- a/src/mongo/db/storage/checkpointer.cpp +++ b/src/mongo/db/storage/checkpointer.cpp @@ -73,6 +73,11 @@ void Checkpointer::run() { ThreadClient tc(name(), getGlobalServiceContext()); LOGV2_DEBUG(22307, 1, "Starting thread", "threadName"_attr = name()); + { + stdx::lock_guard<Client> lk(*tc.get()); + tc.get()->setSystemOperationUnKillableByStepdown(lk); + } + while (true) { auto opCtx = tc->makeOperationContext(); diff --git a/src/mongo/db/storage/control/journal_flusher.cpp b/src/mongo/db/storage/control/journal_flusher.cpp index ebfc1c2718a..81b2e2ee76b 100644 --- a/src/mongo/db/storage/control/journal_flusher.cpp +++ b/src/mongo/db/storage/control/journal_flusher.cpp @@ -80,6 +80,12 @@ void JournalFlusher::run() { ThreadClient tc(name(), getGlobalServiceContext()); LOGV2_DEBUG(4584701, 1, "starting {name} thread", "name"_attr = name()); + // TODO(SERVER-74657): Please revisit if this thread could be made killable. + { + stdx::lock_guard<Client> lk(*tc.get()); + tc.get()->setSystemOperationUnKillableByStepdown(lk); + } + // The thread must not run and access the service context to create an opCtx while unit test // infrastructure is still being set up and expects sole access to the service context (there is // no conurrency control on the service context during this phase). diff --git a/src/mongo/db/storage/oplog_cap_maintainer_thread.cpp b/src/mongo/db/storage/oplog_cap_maintainer_thread.cpp index 337d8230721..555c3764d81 100644 --- a/src/mongo/db/storage/oplog_cap_maintainer_thread.cpp +++ b/src/mongo/db/storage/oplog_cap_maintainer_thread.cpp @@ -107,6 +107,11 @@ void OplogCapMaintainerThread::run() { LOGV2_DEBUG(5295000, 1, "Oplog cap maintainer thread started", "threadName"_attr = _name); ThreadClient tc(_name, getGlobalServiceContext()); + { + stdx::lock_guard<Client> lk(*tc.get()); + tc.get()->setSystemOperationUnKillableByStepdown(lk); + } + while (!globalInShutdownDeprecated()) { if (MONGO_unlikely(hangOplogCapMaintainerThread.shouldFail())) { LOGV2(5095500, "Hanging the oplog cap maintainer thread due to fail point"); diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp index 46798890198..6f60b42705c 100644 --- a/src/mongo/db/storage/storage_engine_impl.cpp +++ b/src/mongo/db/storage/storage_engine_impl.cpp @@ -1343,7 +1343,8 @@ void StorageEngineImpl::TimestampMonitor::_startup() { throw; } }, - Seconds(1)); + Seconds(1), + false /*isKillableByStepdown*/); _job = _periodicRunner->makeJob(std::move(job)); _job.start(); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_prepare_conflict_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_prepare_conflict_test.cpp index aabbcbfc369..cb94e2a20e3 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_prepare_conflict_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_prepare_conflict_test.cpp @@ -69,12 +69,6 @@ public: kvEngine = makeKVEngine(serviceContext, home.path(), &cs); opCtx->setRecoveryUnit(std::unique_ptr<RecoveryUnit>(kvEngine->newRecoveryUnit()), WriteUnitOfWork::RecoveryUnitState::kNotInUnitOfWork); - - // Sets internal states to pass invariants inside 'wiredTigerPrepareConflictRetry()'. - { - stdx::lock_guard<Client> lk(*client); - client->setSystemOperationKillableByStepdown(lk); - } } unittest::TempDir home{"temp"}; |