diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/repl/bgsync.cpp | 18 | ||||
-rw-r--r-- | src/mongo/db/repl/bgsync.h | 2 | ||||
-rw-r--r-- | src/mongo/shell/check_log.js | 15 | ||||
-rw-r--r-- | src/mongo/shell/replsettest.js | 10 |
4 files changed, 26 insertions, 19 deletions
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp index 02cb1daff36..a81b0ebbb11 100644 --- a/src/mongo/db/repl/bgsync.cpp +++ b/src/mongo/db/repl/bgsync.cpp @@ -265,7 +265,7 @@ void BackgroundSync::_produce() { LOGV2(21079, "bgsync - stopReplProducer fail point " "enabled. Blocking until fail point is disabled."); - mongo::sleepsecs(1); + mongo::sleepmillis(_getRetrySleepMS()); return; } @@ -407,10 +407,7 @@ void BackgroundSync::_produce() { // out of date. In that case we sleep for 1 second to reduce the amount we spin waiting // for our map to update. if (oldSource == source) { - long long sleepMS = 1000; - forceBgSyncSyncSourceRetryWaitMS.execute( - [&](const BSONObj& data) { sleepMS = data["sleepMS"].numberInt(); }); - + long long sleepMS = _getRetrySleepMS(); LOGV2(21087, "Chose same sync source candidate as last time, {syncSource}. Sleeping for " "{sleepDurationMillis}ms to avoid immediately choosing a new sync source for the " @@ -439,10 +436,7 @@ void BackgroundSync::_produce() { "error"_attr = syncSourceResp.syncSourceStatus.getStatus()); } - long long sleepMS = 1000; - forceBgSyncSyncSourceRetryWaitMS.execute( - [&](const BSONObj& data) { sleepMS = data["sleepMS"].numberInt(); }); - + long long sleepMS = _getRetrySleepMS(); // No sync source found. LOGV2_DEBUG(21090, 1, @@ -962,6 +956,12 @@ void BackgroundSync::startProducerIfStopped() { } } +long long BackgroundSync::_getRetrySleepMS() { + long long sleepMS = 1000; + forceBgSyncSyncSourceRetryWaitMS.execute( + [&](const BSONObj& data) { sleepMS = data["sleepMS"].numberInt(); }); + return sleepMS; +} } // namespace repl } // namespace mongo diff --git a/src/mongo/db/repl/bgsync.h b/src/mongo/db/repl/bgsync.h index 5e7558fc7bd..3502597a179 100644 --- a/src/mongo/db/repl/bgsync.h +++ b/src/mongo/db/repl/bgsync.h @@ -211,6 +211,8 @@ private: OpTime _readLastAppliedOpTime(OperationContext* opCtx); + long long _getRetrySleepMS(); + // This OplogApplier applies oplog entries fetched from the sync source. OplogApplier* const _oplogApplier; diff --git a/src/mongo/shell/check_log.js b/src/mongo/shell/check_log.js index 82f0792a2b8..fcd70af061c 100644 --- a/src/mongo/shell/check_log.js +++ b/src/mongo/shell/check_log.js @@ -118,13 +118,16 @@ checkLog = (function() { * Calls the 'getLog' function at regular intervals on the provided connection 'conn' until * the provided 'msg' is found in the logs, or it times out. Throws an exception on timeout. */ - let contains = function(conn, msg, timeout = 5 * 60 * 1000) { + let contains = function(conn, msg, timeout = 5 * 60 * 1000, retryIntervalMS = 300) { // Don't run the hang analyzer because we don't expect contains() to always succeed. - assert.soon(function() { - return checkContainsOnce(conn, msg); - }, 'Could not find log entries containing the following message: ' + msg, timeout, 300, { - runHangAnalyzer: false - }); + assert.soon( + function() { + return checkContainsOnce(conn, msg); + }, + 'Could not find log entries containing the following message: ' + msg, + timeout, + retryIntervalMS, + {runHangAnalyzer: false}); }; let containsJson = function(conn, id, attrsDict, timeout = 5 * 60 * 1000) { diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index a2930b60d27..f08a51e239a 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -682,9 +682,10 @@ var ReplSetTest = function(opts) { * if it throws. */ this.awaitSecondaryNodesForRollbackTest = function( - timeout, slaves, connToCheckForUnrecoverableRollback) { + timeout, slaves, connToCheckForUnrecoverableRollback, retryIntervalMS) { + retryIntervalMS = retryIntervalMS || 200; try { - this.awaitSecondaryNodes(timeout, slaves); + this.awaitSecondaryNodes(timeout, slaves, retryIntervalMS); } catch (originalEx) { // There is a special case where we expect the (rare) possibility of unrecoverable // rollbacks with EMRC:false in rollback suites with unclean shutdowns. @@ -1679,12 +1680,13 @@ var ReplSetTest = function(opts) { // Wait until the optime of the specified type reaches the primary's last applied optime. Blocks // on all secondary nodes or just 'slaves', if specified. The timeout will reset if any of the // secondaries makes progress. - this.awaitReplication = function(timeout, secondaryOpTimeType, slaves) { + this.awaitReplication = function(timeout, secondaryOpTimeType, slaves, retryIntervalMS) { if (slaves !== undefined && slaves !== self._slaves) { print("ReplSetTest awaitReplication: going to check only " + slaves.map(s => s.host)); } timeout = timeout || self.kDefaultTimeoutMS; + retryIntervalMS = retryIntervalMS || 200; secondaryOpTimeType = secondaryOpTimeType || ReplSetTest.OpTimeType.LAST_APPLIED; @@ -1878,7 +1880,7 @@ var ReplSetTest = function(opts) { return false; } - }, "awaiting replication", timeout); + }, "awaitReplication timed out", timeout, retryIntervalMS); } }; |