summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheahuychou Mao <mao.cheahuychou@gmail.com>2021-06-11 18:11:43 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-23 14:27:43 +0000
commitfbdfaa2530248b18b4327527f08d83eb283f67a2 (patch)
treea55de7b754b9d9f8fafe913dde2fc14356bda8e6
parentc68f2da49a906f37dc4c81370f87a9e036ac6378 (diff)
downloadmongo-fbdfaa2530248b18b4327527f08d83eb283f67a2.tar.gz
SERVER-55573 Deadlock between stepdown and chunk migration
-rw-r--r--src/mongo/db/s/migration_destination_manager.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp
index c55e1e6fec9..4478a436733 100644
--- a/src/mongo/db/s/migration_destination_manager.cpp
+++ b/src/mongo/db/s/migration_destination_manager.cpp
@@ -480,9 +480,19 @@ repl::OpTime MigrationDestinationManager::cloneDocumentsFromDonor(
repl::OpTime lastOpApplied;
stdx::thread inserterThread{[&] {
- Client::initKillableThread("chunkInserter", opCtx->getServiceContext());
+ Client::initThread("chunkInserter", opCtx->getServiceContext(), nullptr);
+ auto newClient = Client::getCurrent();
+ {
+ stdx::lock_guard lk(*newClient);
+ newClient->setSystemOperationKillable(lk);
+ }
+ auto inserterOpCtx = cc().makeOperationContext();
+ inserterOpCtx->setAlwaysInterruptAtStepDownOrUp();
+ {
+ stdx::lock_guard<Client> lk(*opCtx->getClient());
+ opCtx->checkForInterrupt();
+ }
- auto inserterOpCtx = Client::getCurrent()->makeOperationContext();
auto consumerGuard = makeGuard([&] {
batches.closeConsumerEnd();
lastOpApplied = repl::ReplClientInfo::forClient(inserterOpCtx->getClient()).getLastOp();
@@ -1051,6 +1061,11 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx) {
AlternativeClientRegion acr(newClient);
auto newOpCtxPtr = cc().makeOperationContext();
+ newOpCtxPtr->setAlwaysInterruptAtStepDownOrUp();
+ {
+ stdx::lock_guard<Client> lk(*outerOpCtx->getClient());
+ outerOpCtx->checkForInterrupt();
+ }
auto opCtx = newOpCtxPtr.get();
{