diff options
author | David Storch <david.storch@mongodb.com> | 2021-10-13 22:07:11 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-19 22:27:25 +0000 |
commit | 0aa523559cd68b32f025a8127272ddfbf8a1a30f (patch) | |
tree | bab2c00fc946fa22769d463ae45fc6f68210d43a | |
parent | 55a739ccd3fc41b4b77c2833206fd908991e9d05 (diff) | |
download | mongo-0aa523559cd68b32f025a8127272ddfbf8a1a30f.tar.gz |
SERVER-60586 Fix out_max_time_ms.js to correctly enable 'maxTimeNeverTimeOut' failpoint
(cherry picked from commit fb5fc15108425209fe8b5fb4a33e45e7980214b3)
(cherry picked from commit 96ca0c19edd8673b7851192c33edc1400a23844e)
(cherry picked from commit 48d228aa83ce8c5f36725c5871337d9bc455bc69)
-rw-r--r-- | jstests/noPassthrough/out_max_time_ms.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/jstests/noPassthrough/out_max_time_ms.js b/jstests/noPassthrough/out_max_time_ms.js index c11371d93a9..f66ef7aca45 100644 --- a/jstests/noPassthrough/out_max_time_ms.js +++ b/jstests/noPassthrough/out_max_time_ms.js @@ -20,6 +20,20 @@ function insertDocs(coll) { } } +// A list of connections to all the nodes currently being used by the test. +let connsToAllNodes = []; + +/** + * Prevents premature maxTimeMS expiration by enabling the "maxTimeNeverTimeOut" failpoint on each + * node under test. + */ +function prohibitMaxTimeExpiration() { + for (const conn of connsToAllNodes) { + assert.commandWorked(conn.getDB("admin").runCommand( + {configureFailPoint: "maxTimeNeverTimeOut", mode: "alwaysOn"})); + } +} + /** * Wait until the server sets its CurOp "msg" to the failpoint name, indicating that it's * hanging. @@ -55,12 +69,8 @@ function forceAggregationToHangAndCheckMaxTimeMsExpires( assert.commandWorked(failPointConn.getDB("admin").runCommand(failpointCommand)); - // Make sure we don't run out of time on either of the involved nodes before the failpoint is - // hit. - assert.commandWorked(conn.getDB("admin").runCommand( - {configureFailPoint: "maxTimeNeverTimeOut", mode: "alwaysOn"})); - assert.commandWorked(maxTimeMsConn.getDB("admin").runCommand( - {configureFailPoint: "maxTimeNeverTimeOut", mode: "alwaysOn"})); + // Make sure we don't run out of time on any of the involved nodes before the failpoint is hit. + prohibitMaxTimeExpiration(); // Build the parallel shell function. let shellStr = `const testDB = db.getSiblingDB('${kDBName}');`; @@ -136,6 +146,7 @@ function runUnshardedTest(conn, primaryConn, maxTimeMsConn) { (function() { const conn = MongoRunner.runMongod({}); assert.neq(null, conn, 'mongod was unable to start up'); +connsToAllNodes = [conn]; insertDocs(conn.getDB(kDBName)[kSourceCollName]); runUnshardedTest(conn, conn, conn); MongoRunner.stopMongod(conn); @@ -149,6 +160,7 @@ replTest.initiate(); replTest.awaitReplication(); const primary = replTest.getPrimary(); const secondary = replTest.getSecondary(); +connsToAllNodes = [primary, secondary]; insertDocs(primary.getDB(kDBName)[kSourceCollName]); // Run the $out on the primary and test that the maxTimeMS times out on the primary. runUnshardedTest(primary, primary, primary); |