diff options
Diffstat (limited to 'src/mongo/db/s/balancer_stats_registry.cpp')
-rw-r--r-- | src/mongo/db/s/balancer_stats_registry.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/mongo/db/s/balancer_stats_registry.cpp b/src/mongo/db/s/balancer_stats_registry.cpp index c2308b26d2d..281e6714385 100644 --- a/src/mongo/db/s/balancer_stats_registry.cpp +++ b/src/mongo/db/s/balancer_stats_registry.cpp @@ -30,6 +30,7 @@ #include "mongo/db/s/balancer_stats_registry.h" +#include "mongo/db/catalog_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/pipeline/aggregate_command_gen.h" #include "mongo/db/repl/replication_coordinator.h" @@ -60,23 +61,6 @@ ThreadPool::Options makeDefaultThreadPoolOptions() { } } // namespace -ScopedRangeDeleterLock::ScopedRangeDeleterLock(OperationContext* opCtx) - // TODO SERVER-62491 Use system tenantId for DBLock - : _configLock(opCtx, DatabaseName(boost::none, NamespaceString::kConfigDb), MODE_IX), - _rangeDeletionLock(opCtx, NamespaceString::kRangeDeletionNamespace, MODE_X) {} - -// Take DB and Collection lock in mode IX as well as collection UUID lock to serialize with -// operations that take the above version of the ScopedRangeDeleterLock such as FCV downgrade and -// BalancerStatsRegistry initialization. -ScopedRangeDeleterLock::ScopedRangeDeleterLock(OperationContext* opCtx, const UUID& collectionUuid) - // TODO SERVER-62491 Use system tenantId for DBLock - : _configLock(opCtx, DatabaseName(boost::none, NamespaceString::kConfigDb), MODE_IX), - _rangeDeletionLock(opCtx, NamespaceString::kRangeDeletionNamespace, MODE_IX), - _collectionUuidLock(Lock::ResourceLock( - opCtx->lockState(), - ResourceId(RESOURCE_MUTEX, "RangeDeleterCollLock::" + collectionUuid.toString()), - MODE_X)) {} - const ReplicaSetAwareServiceRegistry::Registerer<BalancerStatsRegistry> balancerStatsRegistryRegisterer("BalancerStatsRegistry"); @@ -133,9 +117,13 @@ void BalancerStatsRegistry::initializeAsync(OperationContext* opCtx) { LOGV2_DEBUG(6419601, 2, "Initializing BalancerStatsRegistry"); try { - // Lock the range deleter to prevent - // concurrent modifications of orphans count - ScopedRangeDeleterLock rangeDeleterLock(opCtx); + // Lock the range deleter to prevent concurrent modifications of orphans count + ScopedRangeDeleterLock rangeDeleterLock(opCtx, LockMode::MODE_S); + // The collection lock is needed to serialize with direct writes to + // config.rangeDeletions + AutoGetCollection rangeDeletionLock( + opCtx, NamespaceString::kRangeDeletionNamespace, MODE_S); + // Load current ophans count from disk _loadOrphansCount(opCtx); LOGV2_DEBUG(6419602, 2, "Completed BalancerStatsRegistry initialization"); |