From a81740843b21c8dcff964bd0a168e9da7cc5225d Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Wed, 23 Oct 2019 15:50:41 +0000 Subject: SERVER-44121 index builds managed by the IndexBuildsCoordinator should always opt out of the PBWM --- src/mongo/db/index_builds_coordinator_mongod.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/mongo/db/index_builds_coordinator_mongod.cpp b/src/mongo/db/index_builds_coordinator_mongod.cpp index 5ceb86110db..45b4465173f 100644 --- a/src/mongo/db/index_builds_coordinator_mongod.cpp +++ b/src/mongo/db/index_builds_coordinator_mongod.cpp @@ -137,10 +137,6 @@ IndexBuildsCoordinatorMongod::startIndexBuild(OperationContext* opCtx, // If the calling thread is replicating oplog writes (primary), this state should be passed to // the builder. const bool writesAreReplicated = opCtx->writesAreReplicated(); - // Index builds on secondaries can't hold the PBWM lock because it would conflict with - // replication. - const bool shouldNotConflictWithSecondaryBatchApplication = - !opCtx->lockState()->shouldConflictWithSecondaryBatchApplication(); // Task in thread pool should have similar CurOp representation to the caller so that it can be // identified as a createIndexes operation. @@ -160,7 +156,6 @@ IndexBuildsCoordinatorMongod::startIndexBuild(OperationContext* opCtx, deadline, timeoutError, writesAreReplicated, - shouldNotConflictWithSecondaryBatchApplication, logicalOp, opDesc, replState @@ -190,11 +185,10 @@ IndexBuildsCoordinatorMongod::startIndexBuild(OperationContext* opCtx, unreplicatedWrites.emplace(opCtx.get()); } - // If the calling thread should not take the PBWM lock, neither should this thread. - boost::optional shouldNotConflictBlock; - if (shouldNotConflictWithSecondaryBatchApplication) { - shouldNotConflictBlock.emplace(opCtx->lockState()); - } + // Index builds should never take the PBWM lock, even on a primary. This allows the index + // to continue running after the node steps down to a secondary. + ShouldNotConflictWithSecondaryBatchApplicationBlock shouldNotConflictBlock( + opCtx->lockState()); { stdx::unique_lock lk(*opCtx->getClient()); -- cgit v1.2.1