diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2020-04-10 04:22:44 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-14 06:30:56 +0000 |
commit | 53b6694ef172411cfe8f5939b010efa35dd4d651 (patch) | |
tree | ff57436f2f702b8edd4212da8c3ce5d72e5d77eb /src/mongo/db/s/collection_sharding_runtime.cpp | |
parent | f32f2f906f8c37145ed2bf64cd8db99d35671a41 (diff) | |
download | mongo-53b6694ef172411cfe8f5939b010efa35dd4d651.tar.gz |
SERVER-47468 Remove public CollectionMetadata references from ScopedCollectionDescription
The CollectionMetadata is intended to be an entirely internal (to
sharding) implementation detail of the services provided by
ScopedCollectionDescription/ScopedOwnershipFilter so should not be seen
at all by non-sharding code.
Diffstat (limited to 'src/mongo/db/s/collection_sharding_runtime.cpp')
-rw-r--r-- | src/mongo/db/s/collection_sharding_runtime.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp index 7c15dee0bf5..1dd07f0be68 100644 --- a/src/mongo/db/s/collection_sharding_runtime.cpp +++ b/src/mongo/db/s/collection_sharding_runtime.cpp @@ -145,7 +145,7 @@ ScopedCollectionDescription CollectionShardingRuntime::getCollectionDescription( << "from the config server", optMetadata); - return {std::move(*optMetadata)}; + return {std::move(optMetadata)}; } ScopedCollectionDescription CollectionShardingRuntime::getCollectionDescription_DEPRECATED() { @@ -154,12 +154,14 @@ ScopedCollectionDescription CollectionShardingRuntime::getCollectionDescription_ if (!optMetadata) return {kUnshardedCollection}; - return {std::move(*optMetadata)}; + return {std::move(optMetadata)}; } -boost::optional<ScopedCollectionDescription> -CollectionShardingRuntime::getCurrentMetadataIfKnown() { - return _getCurrentMetadataIfKnown(boost::none); +boost::optional<CollectionMetadata> CollectionShardingRuntime::getCurrentMetadataIfKnown() { + auto optMetadata = _getCurrentMetadataIfKnown(boost::none); + if (!optMetadata) + return boost::none; + return optMetadata->get(); } void CollectionShardingRuntime::checkShardVersionOrThrow(OperationContext* opCtx) { @@ -308,27 +310,29 @@ boost::optional<ChunkRange> CollectionShardingRuntime::getNextOrphanRange(BSONOb return _metadataManager->getNextOrphanRange(from); } -boost::optional<ScopedCollectionDescription> CollectionShardingRuntime::_getCurrentMetadataIfKnown( +std::shared_ptr<ScopedCollectionDescription::Impl> +CollectionShardingRuntime::_getCurrentMetadataIfKnown( const boost::optional<LogicalTime>& atClusterTime) { stdx::lock_guard lk(_metadataManagerLock); switch (_metadataType) { case MetadataType::kUnknown: - return boost::none; + return nullptr; case MetadataType::kUnsharded: - return ScopedCollectionDescription{kUnshardedCollection}; + return kUnshardedCollection; case MetadataType::kSharded: return _metadataManager->getActiveMetadata(atClusterTime); }; MONGO_UNREACHABLE; } -ScopedCollectionDescription CollectionShardingRuntime::_getMetadataWithVersionCheckAt( +std::shared_ptr<ScopedCollectionDescription::Impl> +CollectionShardingRuntime::_getMetadataWithVersionCheckAt( OperationContext* opCtx, const boost::optional<mongo::LogicalTime>& atClusterTime, TreatUnknownAsUnsharded treatUnknownAsUnsharded) { const auto optReceivedShardVersion = getOperationReceivedVersion(opCtx, _nss); if (!optReceivedShardVersion) - return {kUnshardedCollection}; + return kUnshardedCollection; const auto& receivedShardVersion = *optReceivedShardVersion; @@ -346,11 +350,11 @@ ScopedCollectionDescription CollectionShardingRuntime::_getMetadataWithVersionCh << " is not currently known and needs to be recovered", !ChunkVersion::isIgnoredVersion(receivedShardVersion) && treatUnknownAsUnsharded == TreatUnknownAsUnsharded::kYes); - optCurrentMetadata.emplace(kUnshardedCollection); + optCurrentMetadata = kUnshardedCollection; } - const auto& currentMetadata = *optCurrentMetadata; - auto wantedShardVersion = currentMetadata->getShardVersion(); + const auto& currentMetadata = optCurrentMetadata->get(); + auto wantedShardVersion = currentMetadata.getShardVersion(); { auto criticalSectionSignal = _critSec.getSignal( @@ -367,10 +371,10 @@ ScopedCollectionDescription CollectionShardingRuntime::_getMetadataWithVersionCh } if (ChunkVersion::isIgnoredVersion(receivedShardVersion)) - return {kUnshardedCollection}; + return kUnshardedCollection; if (receivedShardVersion.isWriteCompatibleWith(wantedShardVersion)) - return currentMetadata; + return optCurrentMetadata; StaleConfigInfo sci( _nss, receivedShardVersion, wantedShardVersion, ShardingState::get(opCtx)->shardId()); |