diff options
author | Louis Williams <louis.williams@mongodb.com> | 2020-05-14 11:03:29 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-15 21:21:49 +0000 |
commit | cec3439a2d03fc94a4eec2903c76fe44e4c5b69d (patch) | |
tree | 4c50e1caa7a98ba984f38cbd2481547f03613d79 /src | |
parent | acde566e9fb14bc0dd16e8a676415f63335d7f47 (diff) | |
download | mongo-cec3439a2d03fc94a4eec2903c76fe44e4c5b69d.tar.gz |
SERVER-48137 Use DBLock instead of AutoGetDB in index builds
Index builds do not handle exceptions until a final critical section. AutoGetDB can throw
due to stale database or shard versions, which is checked explicitly when an index build completes.
(cherry picked from commit 5dc21b311ba95877eae491f2f3422402bddd8ee0)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/index_builds_coordinator.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index e8a76ba7237..fee46b90224 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -2055,7 +2055,7 @@ void IndexBuildsCoordinator::_scanCollectionAndInsertKeysIntoSorter( OperationContext* opCtx, std::shared_ptr<ReplIndexBuildState> replState) { // Collection scan and insert into index. { - AutoGetDb autoDb(opCtx, replState->dbName, MODE_IX); + Lock::DBLock autoDb(opCtx, replState->dbName, MODE_IX); const NamespaceStringOrUUID dbAndUUID(replState->dbName, replState->collectionUUID); Lock::CollectionLock collLock(opCtx, dbAndUUID, MODE_IX); @@ -2097,7 +2097,7 @@ void IndexBuildsCoordinator::_insertKeysFromSideTablesWithoutBlockingWrites( // Perform the first drain while holding an intent lock. const NamespaceStringOrUUID dbAndUUID(replState->dbName, replState->collectionUUID); { - AutoGetDb autoDb(opCtx, replState->dbName, MODE_IX); + Lock::DBLock autoDb(opCtx, replState->dbName, MODE_IX); Lock::CollectionLock collLock(opCtx, dbAndUUID, MODE_IX); uassertStatusOK(_indexBuildsManager.drainBackgroundWrites( @@ -2119,7 +2119,7 @@ void IndexBuildsCoordinator::_insertKeysFromSideTablesBlockingWrites( const NamespaceStringOrUUID dbAndUUID(replState->dbName, replState->collectionUUID); // Perform the second drain while stopping writes on the collection. { - AutoGetDb autoDb(opCtx, replState->dbName, MODE_IX); + Lock::DBLock autoDb(opCtx, replState->dbName, MODE_IX); // Unlock RSTL to avoid deadlocks with prepare conflicts and state transitions. See // SERVER-42621. @@ -2150,7 +2150,7 @@ IndexBuildsCoordinator::CommitResult IndexBuildsCoordinator::_insertKeysFromSide const IndexBuildOptions& indexBuildOptions, const Timestamp& commitIndexBuildTimestamp) { - AutoGetDb autoDb(opCtx, replState->dbName, MODE_IX); + Lock::DBLock autoDb(opCtx, replState->dbName, MODE_IX); // Unlock RSTL to avoid deadlocks with prepare conflicts and state transitions caused by waiting // for a a strong collection lock. See SERVER-42621. |