diff options
author | Samy Lanka <samy.lanka@mongodb.com> | 2019-06-06 13:18:27 -0400 |
---|---|---|
committer | Samy Lanka <samy.lanka@mongodb.com> | 2019-06-24 16:45:55 -0400 |
commit | f09aa80495bbd79997eaab415e7acdf8f29c18f9 (patch) | |
tree | 22854f5e4f41be4fc8519c74086d03810776e0a9 /src/mongo/shell/utils.js | |
parent | 18ad465f76bd339e8a902d13bf2dc74171d6e2f1 (diff) | |
download | mongo-f09aa80495bbd79997eaab415e7acdf8f29c18f9.tar.gz |
SERVER-40616 awaitReplication should reset timeout when secondary makes progress
Diffstat (limited to 'src/mongo/shell/utils.js')
-rw-r--r-- | src/mongo/shell/utils.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js index 6d38633e11e..ce840fc5c0f 100644 --- a/src/mongo/shell/utils.js +++ b/src/mongo/shell/utils.js @@ -1541,20 +1541,19 @@ rs.debug.getLastOpWritten = function(server) { return s.oplog.rs.find().sort({$natural: -1}).limit(1).next(); }; +rs.isValidOpTime = function(opTime) { + let timestampIsValid = (opTime.hasOwnProperty("ts") && (opTime.ts !== Timestamp(0, 0))); + let termIsValid = (opTime.hasOwnProperty("t") && (opTime.t != -1)); + + return timestampIsValid && termIsValid; +}; + /** * Compares OpTimes in the format {ts:Timestamp, t:NumberLong}. * Returns -1 if ot1 is 'earlier' than ot2, 1 if 'later' and 0 if equal. */ rs.compareOpTimes = function(ot1, ot2) { - - function _isValidOptime(opTime) { - let timestampIsValid = (opTime.hasOwnProperty("ts") && (opTime.ts !== Timestamp(0, 0))); - let termIsValid = (opTime.hasOwnProperty("t") && (opTime.t != -1)); - - return timestampIsValid && termIsValid; - } - - if (!_isValidOptime(ot1) || !_isValidOptime(ot2)) { + if (!rs.isValidOpTime(ot1) || !rs.isValidOpTime(ot2)) { throw Error("invalid optimes, received: " + tojson(ot1) + " and " + tojson(ot2)); } |