Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2077

Invalid staleness calculation

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.0
    • Affects Version/s: 3.2.6
    • Component/s: None

      Hi there,

      We're using latest mongodb(2.2.36) packages with mongodb-core (2.1.20) and we found that "staleness" calculation is not valid in replsetĀ https://github.com/mongodb-js/mongodb-core/blob/3.1/lib/topologies/replset.js#L442

      Problem is that process.hrtime()[1] is nanoseconds and in this formula should be

      server.lastUpdateTime = hrTime[0] * 1000 + Math.round(hrTime[1] / 1000000);

      Now, formula is result of sum of milliseconds and microseconds which is not correct. It affects secondary and secondaryPreferred read preference logics, and for now it is broken.
      This bug seems to exist at all versions of driver.

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            samat.yusupov@nordigy.ru Samat Yusupov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: