Skip to content

Commit 2eab8aa

Browse files
mbroadstdaprahamian
authored andcommitted
fix(replset): correct legacy max staleness calculation
We were calculating lastUpdateTime using nanoseconds instead of milliseconds, despite calculating maxStaleness with a millisecond lastWriteDate
1 parent 9c5c928 commit 2eab8aa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/core/topologies/replset.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,10 @@ var pingServer = function(self, server, cb) {
415415

416416
// Calculate latency
417417
var latencyMS = new Date().getTime() - start;
418+
418419
// Set the last updatedTime
419-
var hrTime = process.hrtime();
420-
// Calculate the last update time
421-
server.lastUpdateTime = hrTime[0] * 1000 + Math.round(hrTime[1] / 1000);
420+
var hrtime = process.hrtime();
421+
server.lastUpdateTime = (hrtime[0] * 1e9 + hrtime[1]) / 1e6;
422422

423423
// We had an error, remove it from the state
424424
if (err) {

0 commit comments

Comments
 (0)