diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2020-12-10 19:59:43 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-10 20:11:41 +0000 |
commit | 356ad03a6d3a05daa96122c7c39bf7f87f826cb6 (patch) | |
tree | 872cccb329d5aa6a99e96ee6ba0c670d77bc9e19 | |
parent | 91644c4a07c9ebf385b4d2c93e0495779bdfd8ce (diff) | |
download | mongo-356ad03a6d3a05daa96122c7c39bf7f87f826cb6.tar.gz |
Revert "SERVER-51333 setFeatureCompatibilityVersion fails when downgrading from FCV 4.4 to FCV 4.2 with long collection names present"
This reverts commit d1f0d546f21ff900d3a0b083006bf6a4b61657a8.
-rw-r--r-- | jstests/multiVersion/long_collection_names.js | 33 | ||||
-rw-r--r-- | src/mongo/db/commands/set_feature_compatibility_version_command.cpp | 21 |
2 files changed, 24 insertions, 30 deletions
diff --git a/jstests/multiVersion/long_collection_names.js b/jstests/multiVersion/long_collection_names.js index b4e81634dc6..d72b56b3dcf 100644 --- a/jstests/multiVersion/long_collection_names.js +++ b/jstests/multiVersion/long_collection_names.js @@ -67,29 +67,44 @@ conn = MongoRunner.runMongod(restartOpts42); assert.eq(null, conn, 'mongod was able to start with version ' + tojson(restartOpts42)); /** - * Cannot downgrade to FCV 4.2 on a 4.4 binary when long collection names are present. + * Restart with the 4.4 binary to set the FCV to 4.2. */ let restartOpts44 = Object.extend(mongodOptions44, {restart: true}); conn = MongoRunner.runMongod(restartOpts44); assert.neq(null, conn, 'mongod was unable to start with version ' + tojson(restartOpts44)); testDb = conn.getDB(dbName); -assert.commandFailedWithCode(testDb.adminCommand({setFeatureCompatibilityVersion: lastStableFCV}), - ErrorCodes.InvalidNamespace); +assert.commandWorked(testDb.adminCommand({setFeatureCompatibilityVersion: lastStableFCV})); +MongoRunner.stopMongod(conn); /** - * FCV can be set to 4.2 after removing the long collection name. However, we cannot create any new - * collections with long names in FCV 4.2. + * Restart with the 4.2 binary while in FCV 4.2 with long collection names present. This shouldn't + * crash the server. */ +conn = MongoRunner.runMongod(restartOpts42); +assert.neq(null, conn, 'mongod was unable to start with version ' + tojson(restartOpts42)); + testDb = conn.getDB(dbName); -assert.eq(true, testDb.getCollection(longCollName).drop()); -assert.commandWorked(testDb.adminCommand({setFeatureCompatibilityVersion: lastStableFCV})); +// Ensure we have the proper collections. +let collNames = testDb.getCollectionNames(); + +assert.eq(true, collNames.includes(shortCollName)); +assert.eq(true, collNames.includes(longCollName)); + +MongoRunner.stopMongod(conn); + +/** + * Restart with the 4.4 binary while in FCV 4.2. We shouldn't be able to create any collections with + * long names. + */ +conn = MongoRunner.runMongod(restartOpts44); +assert.neq(null, conn, 'mongod was unable to start with version ' + tojson(restartOpts44)); + +testDb = conn.getDB(dbName); // Creating a long collection name on a 4.4 binary with FCV 4.2 should fail. assert.commandFailedWithCode(testDb.createCollection('c'.repeat(8192)), 4862100); -assert.commandFailedWithCode(testDb.createCollection(longCollName), - ErrorCodes.IncompatibleServerVersion); // Running rename within the same database or across two databases should fail for long collection // names. 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 a4e63703057..50815f25fa4 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -33,7 +33,6 @@ #include "mongo/db/auth/authorization_session.h" #include "mongo/db/catalog/coll_mod.h" -#include "mongo/db/catalog/collection_catalog_helper.h" #include "mongo/db/catalog/database.h" #include "mongo/db/catalog/database_holder.h" #include "mongo/db/commands.h" @@ -350,26 +349,6 @@ public: numIndexBuilds == 0U); } - // Cannot downgrade to FCV 4.2 when long collection names are present. - const std::vector<std::string> dbNames = CollectionCatalog::get(opCtx).getAllDbNames(); - for (const auto& dbName : dbNames) { - Lock::DBLock dbLock(opCtx, dbName, MODE_IS); - catalog::forEachCollectionFromDb( - opCtx, dbName, MODE_IS, [&](const Collection* collection) { - const auto collNss = collection->ns(); - uassert(ErrorCodes::InvalidNamespace, - str::stream() - << "Cannot downgrade the cluster when there are long " - << "collection names present. FCV 4.2 limit: " - << NamespaceString::MaxNSCollectionLenFCV42 - << ". Found: " << collNss - << ", but there may be more. Rename or drop the collection", - collNss.size() <= NamespaceString::MaxNSCollectionLenFCV42); - return true; - }); - } - - FeatureCompatibilityVersion::setTargetDowngrade(opCtx); // Safe reconfig introduces a new "term" field in the config document. If the user tries |