diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2020-03-12 19:19:40 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-12 23:33:40 +0000 |
commit | d09c84a0856060c38e58d971599966af8719a454 (patch) | |
tree | 2cf023186262854298d65d72b01566fc528ea118 /jstests/hooks | |
parent | e4736e7d9e327eafe19e1281bb3942978ca3c353 (diff) | |
download | mongo-d09c84a0856060c38e58d971599966af8719a454.tar.gz |
SERVER-44244 Increase transactionLifetimeLimitSecs during validate hook.
Diffstat (limited to 'jstests/hooks')
-rw-r--r-- | jstests/hooks/run_validate_collections.js | 51 | ||||
-rw-r--r-- | jstests/hooks/validate_collections.js | 29 |
2 files changed, 46 insertions, 34 deletions
diff --git a/jstests/hooks/run_validate_collections.js b/jstests/hooks/run_validate_collections.js index eeabba7e10e..029e501cab5 100644 --- a/jstests/hooks/run_validate_collections.js +++ b/jstests/hooks/run_validate_collections.js @@ -10,14 +10,11 @@ assert.eq(typeof db, 'object', 'Invalid `db` object, is the shell connected to a const topology = DiscoverTopology.findConnectedNodes(db.getMongo()); const hostList = []; -let setFCVHost; if (topology.type === Topology.kStandalone) { hostList.push(topology.mongod); - setFCVHost = topology.mongod; } else if (topology.type === Topology.kReplicaSet) { hostList.push(...topology.nodes); - setFCVHost = topology.primary; } else if (topology.type === Topology.kShardedCluster) { hostList.push(...topology.configsvr.nodes); @@ -32,11 +29,53 @@ if (topology.type === Topology.kStandalone) { throw new Error('Unrecognized topology format: ' + tojson(topology)); } } - // Any of the mongos instances can be used for setting FCV. - setFCVHost = topology.mongos.nodes[0]; } else { throw new Error('Unrecognized topology format: ' + tojson(topology)); } -new CollectionValidator().validateNodes(hostList, setFCVHost); +const adminDB = db.getSiblingDB('admin'); +const requiredFCV = jsTest.options().forceValidationWithFeatureCompatibilityVersion; + +let originalFCV; +let originalTransactionLifetimeLimitSeconds; + +if (requiredFCV) { + // 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. + originalTransactionLifetimeLimitSeconds = hostList.map(hostStr => { + const conn = new Mongo(hostStr); + const res = assert.commandWorked( + conn.adminCommand({setParameter: 1, transactionLifetimeLimitSeconds: 24 * 60 * 60})); + return {conn, originalValue: res.was}; + }); + + originalFCV = adminDB.system.version.findOne({_id: 'featureCompatibilityVersion'}); + + if (originalFCV.targetVersion) { + // If a previous FCV upgrade or downgrade was interrupted, then we run the + // setFeatureCompatibilityVersion command to complete it before attempting to set the + // feature compatibility version to 'requiredFCV'. + assert.commandWorked( + adminDB.runCommand({setFeatureCompatibilityVersion: originalFCV.targetVersion})); + checkFCV(adminDB, originalFCV.targetVersion); + } + + // Now that we are certain that an upgrade or downgrade of the FCV is not in progress, ensure + // the 'requiredFCV' is set. + assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: requiredFCV})); +} + +new CollectionValidator().validateNodes(hostList); + +if (originalFCV && originalFCV.version !== requiredFCV) { + assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: originalFCV.version})); +} + +if (originalTransactionLifetimeLimitSeconds) { + for (let {conn, originalValue} of originalTransactionLifetimeLimitSeconds) { + assert.commandWorked( + conn.adminCommand({setParameter: 1, transactionLifetimeLimitSeconds: originalValue})); + } +} })(); diff --git a/jstests/hooks/validate_collections.js b/jstests/hooks/validate_collections.js index 58e1c5bb276..cf7f1be9707 100644 --- a/jstests/hooks/validate_collections.js +++ b/jstests/hooks/validate_collections.js @@ -122,32 +122,10 @@ function CollectionValidator() { } }; - this.validateNodes = function(hostList, setFCVHost) { + this.validateNodes = function(hostList) { // We run the scoped threads in a try/finally block in case any thread throws an exception, // in which case we want to still join all the threads. let threads = []; - let adminDB; - let originalFCV; - - const requiredFCV = jsTest.options().forceValidationWithFeatureCompatibilityVersion; - if (requiredFCV) { - let conn = new Mongo(setFCVHost); - adminDB = conn.getDB('admin'); - originalFCV = adminDB.system.version.findOne({_id: 'featureCompatibilityVersion'}); - - if (originalFCV.targetVersion) { - // If a previous FCV upgrade or downgrade was interrupted, then we run the - // setFeatureCompatibilityVersion command to complete it before attempting to set - // the feature compatibility version to 'requiredFCV'. - assert.commandWorked(adminDB.runCommand( - {setFeatureCompatibilityVersion: originalFCV.targetVersion})); - checkFCV(adminDB, originalFCV.targetVersion); - } - - // Now that we are certain that an upgrade or downgrade of the FCV is not in progress, - // ensure the 'requiredFCV' is set. - assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: requiredFCV})); - } try { hostList.forEach(host => { @@ -167,11 +145,6 @@ function CollectionValidator() { assert.commandWorked(res, 'Collection validation failed'); }); } - - if (originalFCV && originalFCV.version !== requiredFCV) { - assert.commandWorked( - adminDB.runCommand({setFeatureCompatibilityVersion: originalFCV.version})); - } }; } |