summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/metadata_manager.cpp
diff options
context:
space:
mode:
authorSergi Mateo Bellido <sergi.mateo-bellido@mongodb.com>2021-05-18 10:19:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-21 08:37:39 +0000
commitfb131f649e238c388b0af118d4c716ea5d182f28 (patch)
treeba827f31dfda8c904551ea1333376edc3e6dc416 /src/mongo/db/s/metadata_manager.cpp
parentb779af6606bd4133ed29904f8db737872a527832 (diff)
downloadmongo-fb131f649e238c388b0af118d4c716ea5d182f28.tar.gz
SERVER-57022 The CollectionShardingRuntime should be updated when there is an update of the metadata format
(cherry picked from commit 6edab4953a0186e0d062d444682f9f4135a0a4b8)
Diffstat (limited to 'src/mongo/db/s/metadata_manager.cpp')
-rw-r--r--src/mongo/db/s/metadata_manager.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/db/s/metadata_manager.cpp b/src/mongo/db/s/metadata_manager.cpp
index 4a857f4952c..4376b32a2c6 100644
--- a/src/mongo/db/s/metadata_manager.cpp
+++ b/src/mongo/db/s/metadata_manager.cpp
@@ -178,8 +178,13 @@ void MetadataManager::setFilteringMetadata(CollectionMetadata remoteMetadata) {
invariant(_metadata.back()->metadata);
const auto& activeMetadata = _metadata.back()->metadata.get();
- // We already have the same or newer version
- if (remoteMetadata.getCollVersion().isOlderOrEqualThan(activeMetadata.getCollVersion())) {
+ const auto remoteCollVersion = remoteMetadata.getCollVersion();
+ const auto activeCollVersion = activeMetadata.getCollVersion();
+ // Do nothing if the remote version is older than the current active one,
+ // or it is the same and there was not an update on the metadata format.
+ if (remoteCollVersion.isOlderThan(activeCollVersion) ||
+ (remoteCollVersion == activeCollVersion &&
+ remoteCollVersion.getTimestamp() == activeCollVersion.getTimestamp())) {
LOGV2_DEBUG(21984,
1,
"Ignoring incoming metadata update {activeMetadata} for {namespace} because "