Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-43695

Add sleeps to session_test.cpp to account for discrepancy between curTimeMicros and Date_t clock sources [v4.0]

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.14
    • Affects Version/s: None
    • Component/s: Replication
    • None
    • Fully Compatible
    • Repl 2019-11-18
    • 12

      In the "ReportStashedState" and "ReportUnstashedState" unit tests inside session_test.cpp, startWallClockTime value may not be strictly greater than or equal to startTime since the former is measured using curTimeMicros64() and the latter using Date_t::now() which use different clock sources. If the "real" (i.e. absolute) time is, for example, 4.6 milliseconds, then curTimeMicros64() may return 4600, but we would round it down to 4 milliseconds. At the same time, Date_t::now() may return 5 milliseconds, since it is lower precision. So, we may see startTime actually be greater than startWallClockTime. This is just a discrepancy in the unit tests, and not important for how we track these stats in a real system. To prevent this issue in the tests, we can add artificial sleeps to the unit tests after we record startTime but before we record the startWallClockTime value.

            Assignee:
            william.schultz@mongodb.com Will Schultz
            Reporter:
            william.schultz@mongodb.com Will Schultz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: