diff options
author | Faustoleyva54 <fausto.leyva@mongodb.com> | 2022-10-26 18:45:16 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-26 19:45:23 +0000 |
commit | 73fa6daf31440329b55d0971998e8c0359f08392 (patch) | |
tree | bdcaad0371970a2eb9979e3893b5e4bc0781a71c /src/mongo/db/commands | |
parent | 3044115e2f14194d7acdea867400bf6a96aecc17 (diff) | |
download | mongo-73fa6daf31440329b55d0971998e8c0359f08392.tar.gz |
SERVER-67597 Handle new time-series bucketing parameters on downgrade
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r-- | src/mongo/db/commands/set_feature_compatibility_version_command.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp index d73102619d2..dc2e1ffb7c0 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -637,7 +637,8 @@ private: dbName, MODE_S, [&](const CollectionPtr& collection) { - invariant(collection->getTimeseriesOptions()); + auto tsOptions = collection->getTimeseriesOptions(); + invariant(tsOptions); auto indexCatalog = collection->getIndexCatalog(); auto indexIt = indexCatalog->getIndexIterator( @@ -645,10 +646,10 @@ private: IndexCatalog::InclusionPolicy::kReady | IndexCatalog::InclusionPolicy::kUnfinished); + // Check and fail to downgrade if the time-series collection has a + // partial, TTL index. while (indexIt->more()) { auto indexEntry = indexIt->next(); - // Fail to downgrade if the time-series collection has a partial, - // TTL index. if (indexEntry->descriptor()->isPartial()) { // TODO (SERVER-67659): Remove partial, TTL index check once // FCV 7.0 becomes last-lts. @@ -668,6 +669,20 @@ private: IndexDescriptor::kExpireAfterSecondsFieldName)); } } + + // Check the time-series options for a default granularity. Fail the + // downgrade if the bucketing parameters are custom values. + uassert( + ErrorCodes::CannotDowngrade, + str::stream() + << "Cannot downgrade the cluster when there are time-series " + "collections with custom bucketing parameters. In order to " + "downgrade, the time-series collection(s) must be updated " + "with a granularity of 'seconds', 'minutes' or 'hours'. " + "First detected incompatible collection: '" + << collection->ns().getTimeseriesViewNamespace() << "'", + tsOptions->getGranularity().has_value()); + return true; }, [&](const CollectionPtr& collection) { |