Invalid staleness calculation

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.3.0
    • Affects Version/s: 3.2.6
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
              Reporter:
              Samat Yusupov
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: