diff options
Diffstat (limited to 'src/mongo/db/s/collection_sharding_runtime.cpp')
-rw-r--r-- | src/mongo/db/s/collection_sharding_runtime.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp index 4d91e633550..becd6afd89c 100644 --- a/src/mongo/db/s/collection_sharding_runtime.cpp +++ b/src/mongo/db/s/collection_sharding_runtime.cpp @@ -123,11 +123,21 @@ CollectionShardingRuntime* CollectionShardingRuntime::get_UNSAFE(ServiceContext* } ScopedCollectionFilter CollectionShardingRuntime::getOwnershipFilter(OperationContext* opCtx) { + const auto optReceivedShardVersion = getOperationReceivedVersion(opCtx, _nss); + if (!optReceivedShardVersion) + return {kUnshardedCollection}; + const auto atClusterTime = repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime(); auto optMetadata = _getMetadataWithVersionCheckAt(opCtx, atClusterTime); - if (!optMetadata) - return {kUnshardedCollection}; + uassert(StaleConfigInfo(_nss, + *optReceivedShardVersion, + getCurrentShardVersionIfKnown(), + ShardingState::get(opCtx)->shardId()), + str::stream() << "sharding status of collection " << _nss.ns() + << " is not currently available for filtering and needs to be recovered " + << "from the config server", + optMetadata); return {std::move(*optMetadata)}; } @@ -365,7 +375,9 @@ CollectionShardingRuntime::_getMetadataWithVersionCheckAt( if (ChunkVersion::isIgnoredVersion(receivedShardVersion)) { uassert(std::move(sci), - "no metadata found on multi-write operation, need to refresh", + str::stream() + << "sharding status of collection " << _nss.ns() + << " is not currently known and needs to be recovered from the config server", !receivedShardVersion.getCanThrowSSVOnIgnored() || _getCurrentMetadataIfKnown(atClusterTime)); return boost::none; |