diff options
Diffstat (limited to 'src/mongo/db/s/balancer_stats_registry.h')
-rw-r--r-- | src/mongo/db/s/balancer_stats_registry.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/db/s/balancer_stats_registry.h b/src/mongo/db/s/balancer_stats_registry.h index 473285b627c..fdc68ab1021 100644 --- a/src/mongo/db/s/balancer_stats_registry.h +++ b/src/mongo/db/s/balancer_stats_registry.h @@ -38,18 +38,19 @@ namespace mongo { /** - * Acquires the config db lock in IX mode and the collection lock for config.rangeDeletions in X - * mode. + * Scoped lock to synchronize with the execution of range deletions. + * The range-deleter acquires a scoped lock in IX mode while orphans are being deleted. + * Acquiring the scoped lock in MODE_X ensures that no orphan counter in `config.rangeDeletions` + * entries is going to be updated concurrently. */ class ScopedRangeDeleterLock { public: - ScopedRangeDeleterLock(OperationContext* opCtx); - ScopedRangeDeleterLock(OperationContext* opCtx, const UUID& collectionUuid); + ScopedRangeDeleterLock(OperationContext* opCtx, LockMode mode) + : _resourceLock(opCtx, _mutex.getRid(), mode) {} private: - Lock::DBLock _configLock; - Lock::CollectionLock _rangeDeletionLock; - boost::optional<Lock::ResourceLock> _collectionUuidLock; + const Lock::ResourceLock _resourceLock; + static inline const Lock::ResourceMutex _mutex{"ScopedRangeDeleterLock"}; }; /** |