summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/collection_sharding_runtime.cpp
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2019-02-11 13:37:53 -0500
committerBlake Oler <blake.oler@mongodb.com>2019-02-21 10:26:13 -0500
commit5cbcc18f3c1f100deb7124d3d665901e473134b1 (patch)
tree4c9653b45ca40afecf6990d9b6fc6101b27ba7bb /src/mongo/db/s/collection_sharding_runtime.cpp
parent5bd904dff90a0e6332d6d4630053141e6617c5de (diff)
downloadmongo-5cbcc18f3c1f100deb7124d3d665901e473134b1.tar.gz
SERVER-38828 Introduce CollectionShardingRuntimeLock usage to collection critical sections.
Allows us to reduce MODE_X collection locks to MODE_IX when under UninterruptibleLockGuards
Diffstat (limited to 'src/mongo/db/s/collection_sharding_runtime.cpp')
-rw-r--r--src/mongo/db/s/collection_sharding_runtime.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp
index 9836cb116b7..38999e3d7f3 100644
--- a/src/mongo/db/s/collection_sharding_runtime.cpp
+++ b/src/mongo/db/s/collection_sharding_runtime.cpp
@@ -78,7 +78,6 @@ CollectionShardingRuntime::CollectionShardingRuntime(ServiceContext* sc,
NamespaceString nss,
executor::TaskExecutor* rangeDeleterExecutor)
: CollectionShardingState(nss),
- _stateChangeMutex(nss.toString()),
_nss(std::move(nss)),
_metadataManager(std::make_shared<MetadataManager>(sc, _nss, rangeDeleterExecutor)) {
if (isNamespaceAlwaysUnsharded(_nss)) {
@@ -193,13 +192,19 @@ CollectionCriticalSection::CollectionCriticalSection(OperationContext* opCtx, Na
AutoGetCollection::ViewMode::kViewsForbidden,
opCtx->getServiceContext()->getPreciseClockSource()->now() +
Milliseconds(migrationLockAcquisitionMaxWaitMS.load()));
- CollectionShardingState::get(opCtx, _nss)->enterCriticalSectionCatchUpPhase(_opCtx);
+ auto* const csr = CollectionShardingRuntime::get(_opCtx, _nss);
+ auto csrLock = CollectionShardingState::CSRLock::lockExclusive(_opCtx, csr);
+
+ csr->enterCriticalSectionCatchUpPhase(_opCtx, csrLock);
}
CollectionCriticalSection::~CollectionCriticalSection() {
UninterruptibleLockGuard noInterrupt(_opCtx->lockState());
- AutoGetCollection autoColl(_opCtx, _nss, MODE_IX, MODE_X);
- CollectionShardingState::get(_opCtx, _nss)->exitCriticalSection(_opCtx);
+ AutoGetCollection autoColl(_opCtx, _nss, MODE_IX, MODE_IX);
+ auto* const csr = CollectionShardingRuntime::get(_opCtx, _nss);
+ auto csrLock = CollectionShardingRuntime::CSRLock::lockExclusive(_opCtx, csr);
+
+ csr->exitCriticalSection(_opCtx, csrLock);
}
void CollectionCriticalSection::enterCommitPhase() {
@@ -210,7 +215,10 @@ void CollectionCriticalSection::enterCommitPhase() {
AutoGetCollection::ViewMode::kViewsForbidden,
_opCtx->getServiceContext()->getPreciseClockSource()->now() +
Milliseconds(migrationLockAcquisitionMaxWaitMS.load()));
- CollectionShardingState::get(_opCtx, _nss)->enterCriticalSectionCommitPhase(_opCtx);
+ auto* const csr = CollectionShardingRuntime::get(_opCtx, _nss);
+ auto csrLock = CollectionShardingRuntime::CSRLock::lockExclusive(_opCtx, csr);
+
+ csr->enterCriticalSectionCommitPhase(_opCtx, csrLock);
}
} // namespace mongo