diff options
author | samantharitter <samantha.ritter@10gen.com> | 2017-09-07 14:20:32 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2017-09-11 10:48:31 -0400 |
commit | bacb63bbf80d6c9ddfa9d021fdae0748f7894a49 (patch) | |
tree | 5c681f7bf8840eb9cbc6b9adcb5ea20d890525ab | |
parent | 8244b17489f7f6d7daae9920de0fb1ef12e271fc (diff) | |
download | mongo-bacb63bbf80d6c9ddfa9d021fdae0748f7894a49.tar.gz |
SERVER-30740 Disable background session cache refreshing on tests
-rw-r--r-- | buildscripts/resmokelib/core/programs.py | 6 | ||||
-rw-r--r-- | src/mongo/db/logical_session_cache_impl.cpp | 10 | ||||
-rw-r--r-- | src/mongo/shell/servers.js | 15 |
3 files changed, 23 insertions, 8 deletions
diff --git a/buildscripts/resmokelib/core/programs.py b/buildscripts/resmokelib/core/programs.py index ceef27dbe57..379ec111d88 100644 --- a/buildscripts/resmokelib/core/programs.py +++ b/buildscripts/resmokelib/core/programs.py @@ -45,6 +45,12 @@ def mongod_program(logger, executable=None, process_kwargs=None, **kwargs): if "shardsvr" in kwargs and "orphanCleanupDelaySecs" not in suite_set_parameters: suite_set_parameters["orphanCleanupDelaySecs"] = 0 + # The LogicalSessionCache does automatic background refreshes in the server. This is + # race-y for tests, since tests trigger their own immediate refreshes instead. Turn off + # background refreshing for tests. Set in the .yml file to override this. + if "disableLogicalSessionCacheRefresh" not in suite_set_parameters: + suite_set_parameters["disableLogicalSessionCacheRefresh"] = True + _apply_set_parameters(args, suite_set_parameters) shortcut_opts = { diff --git a/src/mongo/db/logical_session_cache_impl.cpp b/src/mongo/db/logical_session_cache_impl.cpp index 5cb38a51b08..e84d431083b 100644 --- a/src/mongo/db/logical_session_cache_impl.cpp +++ b/src/mongo/db/logical_session_cache_impl.cpp @@ -53,6 +53,8 @@ MONGO_EXPORT_STARTUP_SERVER_PARAMETER( int, LogicalSessionCacheImpl::kLogicalSessionDefaultRefresh.count()); +MONGO_EXPORT_STARTUP_SERVER_PARAMETER(disableLogicalSessionCacheRefresh, bool, false); + constexpr int LogicalSessionCacheImpl::kLogicalSessionCacheDefaultCapacity; constexpr Minutes LogicalSessionCacheImpl::kLogicalSessionDefaultRefresh; @@ -64,9 +66,11 @@ LogicalSessionCacheImpl::LogicalSessionCacheImpl(std::unique_ptr<ServiceLiason> _service(std::move(service)), _sessionsColl(std::move(collection)), _cache(options.capacity) { - PeriodicRunner::PeriodicJob job{[this](Client* client) { _periodicRefresh(client); }, - duration_cast<Milliseconds>(_refreshInterval)}; - _service->scheduleJob(std::move(job)); + if (!disableLogicalSessionCacheRefresh) { + PeriodicRunner::PeriodicJob job{[this](Client* client) { _periodicRefresh(client); }, + duration_cast<Milliseconds>(_refreshInterval)}; + _service->scheduleJob(std::move(job)); + } } LogicalSessionCacheImpl::~LogicalSessionCacheImpl() { diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js index 197a980b36e..2b903e5c238 100644 --- a/src/mongo/shell/servers.js +++ b/src/mongo/shell/servers.js @@ -1055,12 +1055,17 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro argArray.push(...['--setParameter', "enableLocalhostAuthBypass=false"]); } - if (jsTest.options().serviceExecutor && - (!programVersion || (parseInt(programVersion.split(".")[0]) >= 3 && - parseInt(programVersion.split(".")[1]) >= 5))) { - if (!argArrayContains("--serviceExecutor")) { - argArray.push(...["--serviceExecutor", jsTest.options().serviceExecutor]); + // New options in 3.5.x + if (!programVersion || (parseInt(programVersion.split(".")[0]) >= 3 && + parseInt(programVersion.split(".")[1]) >= 5)) { + if (jsTest.options().serviceExecutor) { + if (!argArrayContains("--serviceExecutor")) { + argArray.push(...["--serviceExecutor", jsTest.options().serviceExecutor]); + } } + + // Disable background cache refreshing to avoid races in tests + argArray.push(...['--setParameter', "disableLogicalSessionCacheRefresh=true"]); } // Since options may not be backward compatible, mongos options are not |