summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria van Keulen <maria@mongodb.com>2018-05-25 11:37:57 -0400
committerMaria van Keulen <maria@mongodb.com>2018-06-04 16:34:31 -0400
commit52e32f10d3afb7b161747c7fac9a3cb2cf6bf618 (patch)
tree58aa6692acd25a53dfd3e730dc412cd98ef153a9
parent229b3e3cc93c85810ccd9b8504e1f6e60514eb6d (diff)
downloadmongo-52e32f10d3afb7b161747c7fac9a3cb2cf6bf618.tar.gz
SERVER-34595 Increase transactionLifetimeLimitSeconds default in testing
(cherry picked from commit b82fe5e79018662c9c84e28b71034965d0dd836b)
-rw-r--r--buildscripts/resmokelib/core/programs.py8
-rw-r--r--jstests/noPassthrough/read_concern_snapshot_yielding.js7
-rw-r--r--jstests/noPassthrough/transactionLifetimeLimitSeconds_setParameter.js3
-rw-r--r--src/mongo/shell/servers.js42
-rw-r--r--src/mongo/shell/utils.js1
5 files changed, 36 insertions, 25 deletions
diff --git a/buildscripts/resmokelib/core/programs.py b/buildscripts/resmokelib/core/programs.py
index ebce06fb04d..1e8a0cff44c 100644
--- a/buildscripts/resmokelib/core/programs.py
+++ b/buildscripts/resmokelib/core/programs.py
@@ -201,6 +201,14 @@ def mongo_shell_program( # pylint: disable=too-many-branches,too-many-locals,to
mongos_set_parameters = utils.load_yaml(config.MONGOS_SET_PARAMETERS)
test_data["setParametersMongos"] = _format_test_data_set_parameters(mongos_set_parameters)
+ # There's a periodic background thread that checks for and aborts expired transactions.
+ # "transactionLifetimeLimitSeconds" specifies for how long a transaction can run before expiring
+ # and being aborted by the background thread. It defaults to 60 seconds, which is too short to
+ # be reliable for our tests. Setting it to 3 hours, so that it is longer than the 2 hours we
+ # allow JS tests to run before timing them out.
+ if "transactionLifetimeLimitSeconds" not in test_data:
+ test_data["transactionLifetimeLimitSeconds"] = 3 * 60 * 60
+
if "eval_prepend" in kwargs:
eval_sb.append(str(kwargs.pop("eval_prepend")))
diff --git a/jstests/noPassthrough/read_concern_snapshot_yielding.js b/jstests/noPassthrough/read_concern_snapshot_yielding.js
index 98030280298..c7f8cf3ffbe 100644
--- a/jstests/noPassthrough/read_concern_snapshot_yielding.js
+++ b/jstests/noPassthrough/read_concern_snapshot_yielding.js
@@ -29,13 +29,6 @@
return;
}
- // Increase the timeout for the transaction reaper. This will make the test easier to debug if
- // it hangs.
- // TODO SERVER-34595: This should no longer be necessary once the transaction reaper timeout
- // is increased for all noPassthrough tests.
- assert.commandWorked(
- db.adminCommand({"setParameter": 1, transactionLifetimeLimitSeconds: 60 * 60 * 3}));
-
// Set 'internalQueryExecYieldIterations' to 2 to ensure that commands yield on the second try
// (i.e. after they have established a snapshot but before they have returned any documents).
assert.commandWorked(db.adminCommand({setParameter: 1, internalQueryExecYieldIterations: 2}));
diff --git a/jstests/noPassthrough/transactionLifetimeLimitSeconds_setParameter.js b/jstests/noPassthrough/transactionLifetimeLimitSeconds_setParameter.js
index a53fda9ea90..83247e9d627 100644
--- a/jstests/noPassthrough/transactionLifetimeLimitSeconds_setParameter.js
+++ b/jstests/noPassthrough/transactionLifetimeLimitSeconds_setParameter.js
@@ -4,6 +4,9 @@
(function() {
'use strict';
+ // transactionLifetimeLimitSeconds is set to be higher than its default value in test suites.
+ delete TestData.transactionLifetimeLimitSeconds;
+
/**
* Takes a server connection 'conn' and server parameter 'field' and calls getParameter on the
* connection to retrieve the current setting of that server parameter.
diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js
index 3e56a0a3aa4..2e6c927a75d 100644
--- a/src/mongo/shell/servers.js
+++ b/src/mongo/shell/servers.js
@@ -1071,6 +1071,14 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
.length > 0);
}
+ function argArrayContainsSetParameterValue(value) {
+ assert(value.endsWith("="),
+ "Expected value argument to be of the form <parameterName>=");
+ return argArray.some(function(el) {
+ return typeof el === "string" && el.startsWith(value);
+ });
+ }
+
// programName includes the version, e.g., mongod-3.2.
// baseProgramName is the program name without any version information, e.g., mongod.
let programName = argArray[0];
@@ -1095,15 +1103,7 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
}
}
if (jsTest.options().authMechanism && jsTest.options().authMechanism != "SCRAM-SHA-1") {
- var hasAuthMechs = false;
- for (var i in argArray) {
- if (typeof argArray[i] === 'string' &&
- argArray[i].indexOf('authenticationMechanisms') != -1) {
- hasAuthMechs = true;
- break;
- }
- }
- if (!hasAuthMechs) {
+ if (!argArrayContainsSetParameterValue('authenticationMechanisms=')) {
argArray.push(
...['--setParameter',
"authenticationMechanisms=" + jsTest.options().authMechanism]);
@@ -1114,8 +1114,7 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
}
// New options in 3.5.x
- if (!programVersion || (parseInt(programVersion.split(".")[0]) >= 3 &&
- parseInt(programVersion.split(".")[1]) >= 5)) {
+ if (!programMajorMinorVersion || programMajorMinorVersion >= 305) {
if (jsTest.options().serviceExecutor) {
if (!argArrayContains("--serviceExecutor")) {
argArray.push(...["--serviceExecutor", jsTest.options().serviceExecutor]);
@@ -1154,15 +1153,22 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
}
}
- // TODO: Make this unconditional in 3.8.
- if (!programMajorMinorVersion || programMajorMinorVersion > 304) {
- let hasParam = false;
- for (let arg of argArray) {
- if (typeof arg === 'string' && arg.startsWith('orphanCleanupDelaySecs=')) {
- hasParam = true;
+ // New mongod-specific options in 4.0.x
+ if (!programMajorMinorVersion || programMajorMinorVersion >= 400) {
+ if (jsTest.options().transactionLifetimeLimitSeconds !== undefined) {
+ if (!argArrayContainsSetParameterValue(
+ "transactionLifetimeLimitSeconds=")) {
+ argArray.push(
+ ...["--setParameter",
+ "transactionLifetimeLimitSeconds=" +
+ jsTest.options().transactionLifetimeLimitSeconds]);
}
}
- if (!hasParam) {
+ }
+
+ // TODO: Make this unconditional in 3.8.
+ if (!programMajorMinorVersion || programMajorMinorVersion > 304) {
+ if (!argArrayContainsSetParameterValue('orphanCleanupDelaySecs=')) {
argArray.push(...['--setParameter', 'orphanCleanupDelaySecs=1']);
}
}
diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js
index 6c2612a2b03..54ceb590ba5 100644
--- a/src/mongo/shell/utils.js
+++ b/src/mongo/shell/utils.js
@@ -313,6 +313,7 @@ jsTestOptions = function() {
skipCheckDBHashes: TestData.skipCheckDBHashes || false,
traceExceptions: TestData.hasOwnProperty("traceExceptions") ? TestData.traceExceptions
: true,
+ transactionLifetimeLimitSeconds: TestData.transactionLifetimeLimitSeconds
});
}
return _jsTestOptions;