diff options
author | Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com> | 2021-10-01 08:02:37 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-01 08:47:25 +0000 |
commit | 51160fe9bfa37d5ba865b9ee0ea46b5e6fdd2c04 (patch) | |
tree | 0065055f8480ca213953a112845c5a3f01f6ccdb | |
parent | 4e8f0d9a316149f1a1cfeb83b230168b49805cd9 (diff) | |
download | mongo-51160fe9bfa37d5ba865b9ee0ea46b5e6fdd2c04.tar.gz |
SERVER-60372 Get rid of unused ScopedShardVersionCriticalSection
-rw-r--r-- | src/mongo/db/s/shard_filtering_metadata_refresh.cpp | 85 | ||||
-rw-r--r-- | src/mongo/db/s/shard_filtering_metadata_refresh.h | 23 |
2 files changed, 0 insertions, 108 deletions
diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp index c078d5e24ee..968e89bb74d 100644 --- a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp +++ b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp @@ -258,91 +258,6 @@ void onShardVersionMismatch(OperationContext* opCtx, inRecoverOrRefresh->get(opCtx); } -ScopedShardVersionCriticalSection::ScopedShardVersionCriticalSection(OperationContext* opCtx, - NamespaceString nss, - BSONObj reason) - : _opCtx(opCtx), _nss(std::move(nss)), _reason(std::move(reason)) { - - while (true) { - uassert(ErrorCodes::InvalidNamespace, - str::stream() << "Namespace " << nss << " is not a valid collection name", - _nss.isValid()); - - // This acquisition is performed with collection lock MODE_S in order to ensure that any - // ongoing writes have completed and become visible. - // - // DBLock and CollectionLock are used here to avoid throwing further recursive stale config - // errors. - boost::optional<Lock::DBLock> dbLock; - boost::optional<Lock::CollectionLock> collLock; - auto deadline = _opCtx->getServiceContext()->getPreciseClockSource()->now() + - Milliseconds(migrationLockAcquisitionMaxWaitMS.load()); - dbLock.emplace(_opCtx, _nss.db(), MODE_IS, deadline); - collLock.emplace(_opCtx, _nss, MODE_S, deadline); - - auto* const csr = CollectionShardingRuntime::get(_opCtx, _nss); - boost::optional<CollectionShardingRuntime::CSRLock> csrLock = - CollectionShardingRuntime::CSRLock::lockShared(_opCtx, csr); - - if (joinShardVersionOperation(_opCtx, csr, &dbLock, &collLock, &csrLock)) { - continue; - } - - // Make sure metadata are not unknown before entering the critical section - auto metadata = csr->getCurrentMetadataIfKnown(); - if (!metadata) { - csrLock.reset(); - collLock.reset(); - dbLock.reset(); - onShardVersionMismatch(_opCtx, _nss, boost::none); - continue; - } - - csrLock.reset(); - csrLock.emplace(CollectionShardingRuntime::CSRLock::lockExclusive(_opCtx, csr)); - - if (!joinShardVersionOperation(_opCtx, csr, &dbLock, &collLock, &csrLock)) { - CollectionShardingRuntime::get(_opCtx, _nss) - ->enterCriticalSectionCatchUpPhase(*csrLock, _reason); - break; - } - } - - try { - forceShardFilteringMetadataRefresh(_opCtx, _nss); - } catch (const DBException&) { - _cleanup(); - throw; - } -} - -ScopedShardVersionCriticalSection::~ScopedShardVersionCriticalSection() { - _cleanup(); -} - -void ScopedShardVersionCriticalSection::enterCommitPhase() { - auto deadline = _opCtx->getServiceContext()->getPreciseClockSource()->now() + - Milliseconds(migrationLockAcquisitionMaxWaitMS.load()); - // DBLock and CollectionLock are used here to avoid throwing further recursive stale config - // errors. - Lock::DBLock dbLock(_opCtx, _nss.db(), MODE_IS, deadline); - Lock::CollectionLock collLock(_opCtx, _nss, MODE_IS, deadline); - auto* const csr = CollectionShardingRuntime::get(_opCtx, _nss); - auto csrLock = CollectionShardingRuntime::CSRLock::lockExclusive(_opCtx, csr); - csr->enterCriticalSectionCommitPhase(csrLock, _reason); -} - -void ScopedShardVersionCriticalSection::_cleanup() { - UninterruptibleLockGuard noInterrupt(_opCtx->lockState()); - // DBLock and CollectionLock are used here to avoid throwing further recursive stale config - // errors. - Lock::DBLock dbLock(_opCtx, _nss.db(), MODE_IX); - Lock::CollectionLock collLock(_opCtx, _nss, MODE_IX); - auto* const csr = CollectionShardingRuntime::get(_opCtx, _nss); - auto csrLock = CollectionShardingRuntime::CSRLock::lockExclusive(_opCtx, csr); - csr->exitCriticalSection(csrLock, _reason); -} - Status onShardVersionMismatchNoExcept(OperationContext* opCtx, const NamespaceString& nss, boost::optional<ChunkVersion> shardVersionReceived) noexcept { diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.h b/src/mongo/db/s/shard_filtering_metadata_refresh.h index 1c48039c482..84fd1dc7c0e 100644 --- a/src/mongo/db/s/shard_filtering_metadata_refresh.h +++ b/src/mongo/db/s/shard_filtering_metadata_refresh.h @@ -103,27 +103,4 @@ Status onDbVersionMismatchNoExcept( void forceDatabaseRefresh(OperationContext* opCtx, StringData dbName); -/** - * RAII-style class that enters the migration critical section and refresh the filtering - * metadata for the specified collection. The critical section is released when this object - * goes out of scope. - */ -class ScopedShardVersionCriticalSection { - ScopedShardVersionCriticalSection(const ScopedShardVersionCriticalSection&) = delete; - ScopedShardVersionCriticalSection& operator=(const ScopedShardVersionCriticalSection&) = delete; - -public: - ScopedShardVersionCriticalSection(OperationContext* opCtx, NamespaceString nss, BSONObj reason); - ~ScopedShardVersionCriticalSection(); - - void enterCommitPhase(); - -private: - void _cleanup(); - - OperationContext* const _opCtx; - const NamespaceString _nss; - const BSONObj _reason; -}; - } // namespace mongo |