summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2020-12-14 05:22:51 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-12-14 15:00:53 +0000
commit9e445b94436ee8bb9719d84ce0365eb13d49ef95 (patch)
treed7f4723ef13c2a55bdad0dfc6bca935330eb609c
parent73267a2a82d164a3457805c80e2173a5a4f1db60 (diff)
downloadmongo-9e445b94436ee8bb9719d84ce0365eb13d49ef95.tar.gz
SERVER-51333 Skip setFeatureCompatibilityVersion in validation hook when long collection names are present
-rw-r--r--jstests/hooks/run_validate_collections.js25
1 files changed, 19 insertions, 6 deletions
diff --git a/jstests/hooks/run_validate_collections.js b/jstests/hooks/run_validate_collections.js
index c3ad9af2c72..b5cfa442fec 100644
--- a/jstests/hooks/run_validate_collections.js
+++ b/jstests/hooks/run_validate_collections.js
@@ -52,6 +52,22 @@ let originalTransactionLifetimeLimitSeconds;
let skipFCV = false;
if (requiredFCV) {
+ // Can't set the FCV to 4.2 while having long collection names present.
+ adminDB.runCommand("listDatabases").databases.forEach(function(d) {
+ const mdb = adminDB.getSiblingDB(d.name);
+ try {
+ mdb.getCollectionInfos().forEach(function(c) {
+ const namespace = d.name + "." + c.name;
+ const namespaceLenBytes = encodeURIComponent(namespace).length;
+ if (namespaceLenBytes > 120) {
+ skipFCV = true;
+ }
+ });
+ } catch (e) {
+ skipFCV = true;
+ }
+ });
+
// Running the setFeatureCompatibilityVersion command may implicitly involve running a
// multi-statement transaction. We temporarily raise the transactionLifetimeLimitSeconds to be
// 24 hours to avoid spurious failures from it having been set to a lower value.
@@ -74,12 +90,9 @@ if (requiredFCV) {
}
// Now that we are certain that an upgrade or downgrade of the FCV is not in progress, ensure
- // the 'requiredFCV' is set. If we're trying to set the FCV to 4.2 while having long collection
- // name present, we'll get the 'InvalidNamespace' error.
- const fcvRes = adminDB.runCommand({setFeatureCompatibilityVersion: requiredFCV});
- if (!fcvRes.ok) {
- assert.commandFailedWithCode(fcvRes, ErrorCodes.InvalidNamespace);
- skipFCV = true;
+ // the 'requiredFCV' is set.
+ if (!skipFCV) {
+ assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: requiredFCV}));
}
}