diff options
author | Jordi Olivares Provencio <jordi.olivares-provencio@mongodb.com> | 2022-10-26 13:36:03 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-26 14:34:01 +0000 |
commit | 3c2c643e1ae6c0ec51582b565c894f5648f682fc (patch) | |
tree | f8a375652e8ad74766af4b3ac830065da0998daa | |
parent | 6df7c6f17da7c86e144b8471072c5b9383c46263 (diff) | |
download | mongo-3c2c643e1ae6c0ec51582b565c894f5648f682fc.tar.gz |
SERVER-70038 Deprioritize long running index build steps
-rw-r--r-- | src/mongo/db/index_builds_coordinator.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index eb207cfd9e1..bb4f0239bf1 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -40,6 +40,7 @@ #include "mongo/db/catalog/index_build_entry_gen.h" #include "mongo/db/catalog_raii.h" #include "mongo/db/concurrency/exception_util.h" +#include "mongo/db/concurrency/lock_state.h" #include "mongo/db/concurrency/replication_state_transition_lock_guard.h" #include "mongo/db/curop.h" #include "mongo/db/db_raii.h" @@ -2609,6 +2610,12 @@ void IndexBuildsCoordinator::_scanCollectionAndInsertSortedKeysIntoIndex( std::shared_ptr<ReplIndexBuildState> replState, const boost::optional<RecordId>& resumeAfterRecordId) { // Collection scan and insert into index. + + // The collection scan phase of an index build is marked as low priority in order to reduce + // impact on user operations. Other steps of the index builds such as the draining phase have + // normal priority because index builds are required to eventually catch-up with concurrent + // writers. Otherwise we risk never finishing the index build. + SetTicketAquisitionPriorityForLock priority(opCtx, AdmissionContext::Priority::kLow); { indexBuildsSSS.scanCollection.addAndFetch(1); @@ -2639,6 +2646,11 @@ void IndexBuildsCoordinator::_scanCollectionAndInsertSortedKeysIntoIndex( void IndexBuildsCoordinator::_insertSortedKeysIntoIndexForResume( OperationContext* opCtx, std::shared_ptr<ReplIndexBuildState> replState) { + // The collection scan phase of an index build is marked as low priority in order to reduce + // impact on user operations. Other steps of the index builds such as the draining phase have + // normal priority because index builds are required to eventually catch-up with concurrent + // writers. Otherwise we risk never finishing the index build. + SetTicketAquisitionPriorityForLock priority(opCtx, AdmissionContext::Priority::kLow); { Lock::DBLock autoDb(opCtx, replState->dbName, MODE_IX); const NamespaceStringOrUUID dbAndUUID(replState->dbName, replState->collectionUUID); |