diff options
author | Benety Goh <benety@mongodb.com> | 2019-10-23 15:50:41 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-23 15:50:41 +0000 |
commit | a81740843b21c8dcff964bd0a168e9da7cc5225d (patch) | |
tree | a2647aaac94c5a2c4f9735a9c1cd7918578c0956 | |
parent | 35fbf9bc919f0645b1269cd9916ce2509617e072 (diff) | |
download | mongo-a81740843b21c8dcff964bd0a168e9da7cc5225d.tar.gz |
SERVER-44121 index builds managed by the IndexBuildsCoordinator should always opt out of the PBWM
-rw-r--r-- | src/mongo/db/index_builds_coordinator_mongod.cpp | 14 |
1 files 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<ShouldNotConflictWithSecondaryBatchApplicationBlock> 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<Client> lk(*opCtx->getClient()); |