summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/collection_sharding_runtime.cpp
diff options
context:
space:
mode:
authorAllison Easton <allison.easton@mongodb.com>2022-08-26 08:53:28 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-26 09:51:37 +0000
commiteda533b781990de451847a8bff5d22176fb9ea4b (patch)
treef8209d0212ad69a565e717c893732e1c7688bd4f /src/mongo/db/s/collection_sharding_runtime.cpp
parentdcbfdf202ac012b822260f6be37200c0084fe139 (diff)
downloadmongo-eda533b781990de451847a8bff5d22176fb9ea4b.tar.gz
SERVER-68891 StaleConfigInfo should use shard version
Diffstat (limited to 'src/mongo/db/s/collection_sharding_runtime.cpp')
-rw-r--r--src/mongo/db/s/collection_sharding_runtime.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp
index 15f6bc03fb0..df80079487c 100644
--- a/src/mongo/db/s/collection_sharding_runtime.cpp
+++ b/src/mongo/db/s/collection_sharding_runtime.cpp
@@ -144,8 +144,7 @@ ScopedCollectionDescription CollectionShardingRuntime::getCollectionDescription(
const auto receivedShardVersion{oss.getShardVersion(_nss)};
uassert(
StaleConfigInfo(_nss,
- receivedShardVersion ? (ChunkVersion)*receivedShardVersion
- : ChunkVersion::IGNORED(),
+ receivedShardVersion ? *receivedShardVersion : ShardVersion::IGNORED(),
boost::none /* wantedVersion */,
ShardingState::get(_serviceContext)->shardId()),
str::stream() << "sharding status of collection " << _nss.ns()
@@ -355,7 +354,7 @@ CollectionShardingRuntime::_getMetadataWithVersionCheckAt(
// Assume that the received shard version was IGNORED if the current operation wasn't versioned
const auto& receivedShardVersion =
- optReceivedShardVersion ? (ChunkVersion)*optReceivedShardVersion : ChunkVersion::IGNORED();
+ optReceivedShardVersion ? *optReceivedShardVersion : ShardVersion::IGNORED();
auto csrLock = CSRLock::lockShared(opCtx, this);
@@ -388,10 +387,12 @@ CollectionShardingRuntime::_getMetadataWithVersionCheckAt(
const auto& currentMetadata = optCurrentMetadata->get();
- auto wantedShardVersion = currentMetadata.getShardVersion();
+ const auto wantedPlacementVersion = currentMetadata.getShardVersion();
+ const auto wantedShardVersion = ShardVersion(wantedPlacementVersion);
+ const ChunkVersion receivedPlacementVersion = receivedShardVersion;
if (wantedShardVersion.isWriteCompatibleWith(receivedShardVersion) ||
- ChunkVersion::isIgnoredVersion(receivedShardVersion))
+ receivedShardVersion == ShardVersion::IGNORED())
return optCurrentMetadata;
StaleConfigInfo sci(
@@ -401,13 +402,13 @@ CollectionShardingRuntime::_getMetadataWithVersionCheckAt(
str::stream() << "timestamp mismatch detected for " << _nss.ns(),
wantedShardVersion.isSameCollection(receivedShardVersion));
- if (!wantedShardVersion.isSet() && receivedShardVersion.isSet()) {
+ if (!wantedPlacementVersion.isSet() && receivedPlacementVersion.isSet()) {
uasserted(std::move(sci),
str::stream() << "this shard no longer contains chunks for " << _nss.ns() << ", "
<< "the collection may have been dropped");
}
- if (wantedShardVersion.isSet() && !receivedShardVersion.isSet()) {
+ if (wantedPlacementVersion.isSet() && !receivedPlacementVersion.isSet()) {
uasserted(std::move(sci),
str::stream() << "this shard contains chunks for " << _nss.ns() << ", "
<< "but the client expects unsharded collection");