summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorJiawei Yang <jiawei.yang@mongodb.com>2023-03-29 18:42:16 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-30 18:51:41 +0000
commitb5f1d6bb8c06742cde53f028fd266eff584a2537 (patch)
treeed87f3936e635da175b860359aba30ff15424487 /src/mongo/db/repl
parent4714df5896ddaa06f3146531d2283a013f903996 (diff)
downloadmongo-b5f1d6bb8c06742cde53f028fd266eff584a2537.tar.gz
Revert "SERVER-70127 change system operation threads to be killable by default"
This reverts commit 9f2867c9da77e2d64df3852f7d4578f10e6f0817. Revert "SERVER-75352 OplogBatcher's ReplBatcher thread should be unkillable" This reverts commit 26266d5b736f90961a328399dea5d299cd407ab2.
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/bgsync.cpp5
-rw-r--r--src/mongo/db/repl/noop_writer.cpp1
-rw-r--r--src/mongo/db/repl/oplog_applier.cpp4
-rw-r--r--src/mongo/db/repl/oplog_applier_impl.cpp5
-rw-r--r--src/mongo/db/repl/oplog_batcher.cpp7
-rw-r--r--src/mongo/db/repl/primary_only_service.cpp3
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp6
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp5
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp8
-rw-r--r--src/mongo/db/repl/rollback_test_fixture.cpp5
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp6
-rw-r--r--src/mongo/db/repl/tenant_migration_donor_service.cpp11
-rw-r--r--src/mongo/db/repl/topology_version_observer.cpp6
-rw-r--r--src/mongo/db/repl/transaction_oplog_application.cpp7
-rw-r--r--src/mongo/db/repl/wait_for_majority_service.cpp10
15 files changed, 18 insertions, 71 deletions
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp
index 3d7c0b325d3..340aca59e80 100644
--- a/src/mongo/db/repl/bgsync.cpp
+++ b/src/mongo/db/repl/bgsync.cpp
@@ -226,11 +226,6 @@ void BackgroundSync::_run() {
Client::initThread("BackgroundSync");
AuthorizationSession::get(cc())->grantInternalAuthorization(&cc());
- {
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationUnKillableByStepdown(lk);
- }
-
while (!inShutdown()) {
try {
_runProducer();
diff --git a/src/mongo/db/repl/noop_writer.cpp b/src/mongo/db/repl/noop_writer.cpp
index 74a3312c30a..4bf8188010b 100644
--- a/src/mongo/db/repl/noop_writer.cpp
+++ b/src/mongo/db/repl/noop_writer.cpp
@@ -83,7 +83,6 @@ public:
private:
void run(Seconds waitTime, NoopWriteFn noopWrite) {
Client::initThread("NoopWriter");
-
while (true) {
const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext();
OperationContext& opCtx = *opCtxPtr;
diff --git a/src/mongo/db/repl/oplog_applier.cpp b/src/mongo/db/repl/oplog_applier.cpp
index 2d0493e5c39..af33eaf9633 100644
--- a/src/mongo/db/repl/oplog_applier.cpp
+++ b/src/mongo/db/repl/oplog_applier.cpp
@@ -171,9 +171,9 @@ std::unique_ptr<ThreadPool> makeReplWriterPool(int threadCount,
auto client = Client::getCurrent();
AuthorizationSession::get(*client)->grantInternalAuthorization(client);
- if (!isKillableByStepdown) {
+ if (isKillableByStepdown) {
stdx::lock_guard<Client> lk(*client);
- client->setSystemOperationUnKillableByStepdown(lk);
+ client->setSystemOperationKillableByStepdown(lk);
}
};
auto pool = std::make_unique<ThreadPool>(options);
diff --git a/src/mongo/db/repl/oplog_applier_impl.cpp b/src/mongo/db/repl/oplog_applier_impl.cpp
index 83c15ae106c..7617e6afd46 100644
--- a/src/mongo/db/repl/oplog_applier_impl.cpp
+++ b/src/mongo/db/repl/oplog_applier_impl.cpp
@@ -285,11 +285,6 @@ void ApplyBatchFinalizerForJournal::record(const OpTimeAndWallTime& newOpTimeAnd
void ApplyBatchFinalizerForJournal::_run() {
Client::initThread("ApplyBatchFinalizerForJournal");
- {
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationUnKillableByStepdown(lk);
- }
-
while (true) {
OpTimeAndWallTime latestOpTimeAndWallTime = {OpTime(), Date_t()};
diff --git a/src/mongo/db/repl/oplog_batcher.cpp b/src/mongo/db/repl/oplog_batcher.cpp
index f606c0bae03..9d5edbd2bb5 100644
--- a/src/mongo/db/repl/oplog_batcher.cpp
+++ b/src/mongo/db/repl/oplog_batcher.cpp
@@ -273,13 +273,6 @@ void OplogBatcher::_consume(OperationContext* opCtx, OplogBuffer* oplogBuffer) {
void OplogBatcher::_run(StorageInterface* storageInterface) {
Client::initThread("ReplBatcher");
- {
- // The OplogBatcher's thread has its own shutdown sequence triggered by the OplogApplier,
- // so we don't want it to be killed in other ways.
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationUnKillableByStepdown(lk);
- }
-
BatchLimits batchLimits;
while (true) {
diff --git a/src/mongo/db/repl/primary_only_service.cpp b/src/mongo/db/repl/primary_only_service.cpp
index b3513e481fa..44c2d446cbf 100644
--- a/src/mongo/db/repl/primary_only_service.cpp
+++ b/src/mongo/db/repl/primary_only_service.cpp
@@ -335,6 +335,9 @@ void PrimaryOnlyService::startup(OperationContext* opCtx) {
auto client = Client::getCurrent();
AuthorizationSession::get(*client)->grantInternalAuthorization(&cc());
+ stdx::lock_guard<Client> lk(*client);
+ client->setSystemOperationKillableByStepdown(lk);
+
// Associate this Client with this PrimaryOnlyService
primaryOnlyServiceStateForClient(client).primaryOnlyService = this;
};
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index 7342f419fb7..fabe5d1f02e 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -147,12 +147,6 @@ auto makeThreadPool(const std::string& poolName, const std::string& threadName)
threadPoolOptions.poolName = poolName;
threadPoolOptions.onCreateThread = [](const std::string& threadName) {
Client::initThread(threadName.c_str());
-
- {
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationUnKillableByStepdown(lk);
- }
-
AuthorizationSession::get(cc())->grantInternalAuthorization(&cc());
};
return std::make_unique<ThreadPool>(threadPoolOptions);
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 113f911bc0d..83be62085c9 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -2651,11 +2651,6 @@ void ReplicationCoordinatorImpl::AutoGetRstlForStepUpStepDown::_killOpThreadFn()
invariant(!cc().isFromUserConnection());
- {
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationUnKillableByStepdown(lk);
- }
-
LOGV2(21343, "Starting to kill user operations");
auto uniqueOpCtx = cc().makeOperationContext();
OperationContext* opCtx = uniqueOpCtx.get();
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index 291383fef85..744e1cf824f 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -116,10 +116,7 @@ void ReplCoordTest::addSelf(const HostAndPort& selfHost) {
void ReplCoordTest::init() {
invariant(!_repl);
invariant(!_callShutdown);
- {
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationUnKillableByStepdown(lk);
- }
+
auto service = getGlobalServiceContext();
_storageInterface = new StorageInterfaceMock();
StorageInterface::set(service, std::unique_ptr<StorageInterface>(_storageInterface));
@@ -163,9 +160,6 @@ void ReplCoordTest::init() {
executor::ThreadPoolMock::Options tpOptions;
tpOptions.onCreateThread = []() {
Client::initThread("replexec");
-
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationUnKillableByStepdown(lk);
};
auto pool = std::make_unique<executor::ThreadPoolMock>(_net, seed, tpOptions);
auto replExec =
diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp
index 511bf2fc298..f88973b38b9 100644
--- a/src/mongo/db/repl/rollback_test_fixture.cpp
+++ b/src/mongo/db/repl/rollback_test_fixture.cpp
@@ -88,10 +88,7 @@ public:
void RollbackTest::setUp() {
ServiceContextMongoDTest::setUp();
- {
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationUnKillableByStepdown(lk);
- }
+
_storageInterface = new StorageInterfaceRollback();
auto serviceContext = getServiceContext();
auto consistencyMarkers = std::make_unique<ReplicationConsistencyMarkersMock>();
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index b1d42571985..0c8a3614aed 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -225,12 +225,6 @@ StorageInterfaceImpl::createCollectionForBulkLoading(
auto opCtx = cc().makeOperationContext();
opCtx->setEnforceConstraints(false);
- // TODO(SERVER-74656): Please revisit if this thread could be made killable.
- {
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationUnKillableByStepdown(lk);
- }
-
// DocumentValidationSettings::kDisableInternalValidation is currently inert.
// But, it's logically ok to disable internal validation as this function gets called
// only during initial sync.
diff --git a/src/mongo/db/repl/tenant_migration_donor_service.cpp b/src/mongo/db/repl/tenant_migration_donor_service.cpp
index 0cac61b3888..1775b8479a1 100644
--- a/src/mongo/db/repl/tenant_migration_donor_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_donor_service.cpp
@@ -382,6 +382,17 @@ TenantMigrationDonorService::Instance::_makeRecipientCmdExecutor() {
Client::initThread(threadName.c_str());
auto client = Client::getCurrent();
AuthorizationSession::get(*client)->grantInternalAuthorization(&cc());
+
+ // Ideally, we should also associate the client created by _recipientCmdExecutor with the
+ // TenantMigrationDonorService to make the opCtxs created by the task executor get
+ // registered in the TenantMigrationDonorService, and killed on stepdown. But that would
+ // require passing the pointer to the TenantMigrationService into the Instance and making
+ // constructInstance not const so we can set the client's decoration here. Right now there
+ // is no need for that since the task executor is only used with scheduleRemoteCommand and
+ // no opCtx will be created (the cancellation token is responsible for canceling the
+ // outstanding work on the task executor).
+ stdx::lock_guard<Client> lk(*client);
+ client->setSystemOperationKillableByStepdown(lk);
};
auto hookList = std::make_unique<rpc::EgressMetadataHookList>();
diff --git a/src/mongo/db/repl/topology_version_observer.cpp b/src/mongo/db/repl/topology_version_observer.cpp
index 4c29ec8d972..07eb6c5f327 100644
--- a/src/mongo/db/repl/topology_version_observer.cpp
+++ b/src/mongo/db/repl/topology_version_observer.cpp
@@ -178,12 +178,6 @@ void TopologyVersionObserver::_workerThreadBody() noexcept try {
invariant(_serviceContext);
ThreadClient tc(kTopologyVersionObserverName, _serviceContext);
- // TODO(SERVER-74656): Please revisit if this thread could be made killable.
- {
- stdx::lock_guard<Client> lk(*tc.get());
- tc.get()->setSystemOperationUnKillableByStepdown(lk);
- }
-
auto getTopologyVersion = [&]() -> boost::optional<TopologyVersion> {
// Only the observer thread updates `_cache`, thus there is no need to hold the lock before
// accessing `_cache` here.
diff --git a/src/mongo/db/repl/transaction_oplog_application.cpp b/src/mongo/db/repl/transaction_oplog_application.cpp
index 0ae8e8b5a02..458691eaade 100644
--- a/src/mongo/db/repl/transaction_oplog_application.cpp
+++ b/src/mongo/db/repl/transaction_oplog_application.cpp
@@ -794,13 +794,6 @@ void reconstructPreparedTransactions(OperationContext* opCtx, repl::OplogApplica
// transaction oplog entry.
auto newClient =
opCtx->getServiceContext()->makeClient("reconstruct-prepared-transactions");
-
- // TODO(SERVER-74656): Please revisit if this thread could be made killable.
- {
- stdx::lock_guard<Client> lk(*newClient.get());
- newClient.get()->setSystemOperationUnKillableByStepdown(lk);
- }
-
AlternativeClientRegion acr(newClient);
const auto newOpCtx = cc().makeOperationContext();
diff --git a/src/mongo/db/repl/wait_for_majority_service.cpp b/src/mongo/db/repl/wait_for_majority_service.cpp
index 37b34f35d1c..37d6407e0fe 100644
--- a/src/mongo/db/repl/wait_for_majority_service.cpp
+++ b/src/mongo/db/repl/wait_for_majority_service.cpp
@@ -107,16 +107,6 @@ void WaitForMajorityServiceImplBase::startup(ServiceContext* ctx) {
ClientStrand::make(ctx->makeClient(kWaitClientName + _getReadOrWrite()));
_waitForMajorityCancellationClient =
ClientStrand::make(ctx->makeClient(kCancelClientName + _getReadOrWrite()));
- // TODO(SERVER-74656): Please revisit if this thread could be made killable.
- {
- stdx::lock_guard<Client> lk(*_waitForMajorityClient->getClientPointer());
- _waitForMajorityClient->getClientPointer()->setSystemOperationUnKillableByStepdown(lk);
- }
- {
- stdx::lock_guard<Client> lk(*_waitForMajorityCancellationClient->getClientPointer());
- _waitForMajorityCancellationClient->getClientPointer()
- ->setSystemOperationUnKillableByStepdown(lk);
- }
_backgroundWorkComplete = _periodicallyWaitForMajority();
_pool->startup();
_state = State::kRunning;