diff options
author | Leonardo Menti <leonardo.menti@mongodb.com> | 2022-09-08 14:59:24 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-08 18:19:18 +0000 |
commit | 22608cb9c7b2ce3771855dcb7d7fd6f564df4821 (patch) | |
tree | 3cad18f9c127fad3c6eca702d355dd9bb3eb1d2b /src/mongo/db/commands | |
parent | 17dc0a48233b4c7c6e95b43236f0fc8dba2d3b4e (diff) | |
download | mongo-22608cb9c7b2ce3771855dcb7d7fd6f564df4821.tar.gz |
SERVER-67246 Remove size multiple restriction on capped collections
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r-- | src/mongo/db/commands/set_feature_compatibility_version_command.cpp | 24 |
1 files changed, 24 insertions, 0 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 4a5add8b4b2..24839c2ca59 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -674,6 +674,30 @@ private: }); } } + + if (!feature_flags::gfeatureFlagCappedCollectionsRelaxedSize.isEnabled( + serverGlobalParams.featureCompatibility)) { + for (const auto& dbName : DatabaseHolder::get(opCtx)->getNames()) { + Lock::DBLock dbLock(opCtx, dbName, MODE_IX); + catalog::forEachCollectionFromDb( + opCtx, + dbName, + MODE_S, + [&](const CollectionPtr& collection) { + uasserted( + ErrorCodes::CannotDowngrade, + str::stream() + << "Cannot downgrade the cluster when there are capped " + "collection with a size that is non multiple of 256 bytes. " + "Drop or resize the following collection: '" + << collection->ns() << "'"); + return true; + }, + [&](const CollectionPtr& collection) { + return collection->isCapped() && collection->getCappedMaxSize() % 256 != 0; + }); + } + } } // This helper function is for any internal server downgrade cleanup, such as dropping |