diff options
author | Denis Grebennicov <denis.grebennicov@mongodb.com> | 2023-02-17 09:30:58 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-17 10:37:23 +0000 |
commit | a0ed1b8b5c5c0df47e36f1c1be6560cac924f2c1 (patch) | |
tree | c52e356d209c78d26e6704c6fe31c4e87ba5e1cd /src/mongo/db/commands | |
parent | 7979eacf75188e01f86d044228dfb5ff0b532b84 (diff) | |
download | mongo-a0ed1b8b5c5c0df47e36f1c1be6560cac924f2c1.tar.gz |
SERVER-73833 Make the server to ignore and automatically remove unsupported 'recordPreImages' collection option
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r-- | src/mongo/db/commands/set_feature_compatibility_version_command.cpp | 32 |
1 files changed, 29 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 507ec954bec..ae671e4a8b9 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -565,10 +565,9 @@ private: _createSchemaOnConfigSettings(opCtx, requestedVersion); _initializePlacementHistory(opCtx, requestedVersion); _setOnCurrentShardSinceFieldOnChunks(opCtx, requestedVersion); - } else if (serverGlobalParams.clusterRole == ClusterRole::ShardServer) { - } else { - return; } + + _removeRecordPreImagesCollectionOption(opCtx); } // TODO SERVER-68889 remove once 7.0 becomes last LTS @@ -676,6 +675,33 @@ private: } } + // Removes collection option "recordPreImages" from all collection definitions. + // TODO SERVER-74036: Remove once FCV 7.0 becomes last-LTS. + void _removeRecordPreImagesCollectionOption(OperationContext* opCtx) { + for (const auto& dbName : DatabaseHolder::get(opCtx)->getNames()) { + Lock::DBLock dbLock(opCtx, dbName, MODE_IX); + catalog::forEachCollectionFromDb( + opCtx, + dbName, + MODE_X, + [&](const Collection* collection) { + // To remove collection option "recordPreImages" from persistent storage, issue + // the "collMod" command with none of the parameters set. + BSONObjBuilder responseBuilder; + uassertStatusOK(processCollModCommand( + opCtx, collection->ns(), CollMod{collection->ns()}, &responseBuilder)); + LOGV2(7383300, + "Removed 'recordPreImages' collection option", + "ns"_attr = collection->ns(), + "collModResponse"_attr = responseBuilder.obj()); + return true; + }, + [&](const Collection* collection) { + return collection->getCollectionOptions().recordPreImagesOptionUsed; + }); + } + } + // _runUpgrade performs all the upgrade specific code for setFCV. Any new feature specific // upgrade code should be placed in the _runUpgrade helper functions: // * _prepareForUpgrade: for any upgrade actions that should be done before taking the FCV full |