Skip to content

Commit

Permalink
fix(replset): correct legacy max staleness calculation
Browse files Browse the repository at this point in the history
We were calculating lastUpdateTime using nanoseconds instead of
milliseconds, despite calculating maxStaleness with a millisecond
lastWriteDate
  • Loading branch information
mbroadst authored and daprahamian committed Aug 13, 2019
1 parent 9c5c928 commit 2eab8aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/core/topologies/replset.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ var pingServer = function(self, server, cb) {

// Calculate latency
var latencyMS = new Date().getTime() - start;

// Set the last updatedTime
var hrTime = process.hrtime();
// Calculate the last update time
server.lastUpdateTime = hrTime[0] * 1000 + Math.round(hrTime[1] / 1000);
var hrtime = process.hrtime();
server.lastUpdateTime = (hrtime[0] * 1e9 + hrtime[1]) / 1e6;

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

0 comments on commit 2eab8aa

Please sign in to comment.