diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2023-01-31 18:15:59 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-01 19:59:08 +0000 |
commit | e0fd004387a3ec6668f0a3dfba9c5cdbbf1be71f (patch) | |
tree | 7b50156e9463747a453f42801df6ab98b0342c64 | |
parent | c817aac301a3161e843daa067aaccbad2523db3f (diff) | |
download | mongo-e0fd004387a3ec6668f0a3dfba9c5cdbbf1be71f.tar.gz |
SERVER-73266 Avoid retaking RSTL without timeout at index build commit
(cherry picked from commit 35370b26c155a89a540137fe168da98175a431bf)
-rw-r--r-- | src/mongo/db/index_builds_coordinator.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index b4fd8d4c5a4..2e27a45b522 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -2681,8 +2681,6 @@ IndexBuildsCoordinator::CommitResult IndexBuildsCoordinator::_insertKeysFromSide // Need to return the collection lock back to exclusive mode to complete the index build. const NamespaceStringOrUUID dbAndUUID(replState->dbName, replState->collectionUUID); Lock::CollectionLock collLock(opCtx, dbAndUUID, MODE_X); - AutoGetCollection indexBuildEntryColl( - opCtx, NamespaceString::kIndexBuildEntryNamespace, MODE_IX); // If we can't acquire the RSTL within a given time period, there is an active state transition // and we should release our locks and try again. We would otherwise introduce a deadlock with @@ -2704,6 +2702,9 @@ IndexBuildsCoordinator::CommitResult IndexBuildsCoordinator::_insertKeysFromSide return CommitResult::kLockTimeout; } + AutoGetCollection indexBuildEntryColl( + opCtx, NamespaceString::kIndexBuildEntryNamespace, MODE_IX); + // If we are no longer primary after receiving a commit quorum, we must restart and wait for a // new signal from a new primary because we cannot commit. Note that two-phase index builds can // retry because a new signal should be received. Single-phase builds will be unable to commit |