[SERVER-43695] Add sleeps to session_test.cpp to account for discrepancy between curTimeMicros and Date_t clock sources [v4.0] Created: 27/Sep/19  Updated: 29/Oct/23  Resolved: 12/Nov/19

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 4.0.14

Type: Task Priority: Major - P3
Reporter: William Schultz (Inactive) Assignee: William Schultz (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to SERVER-45761 Use same clock for test and working c... Closed
Backwards Compatibility: Fully Compatible
Sprint: Repl 2019-11-18
Participants:
Linked BF Score: 12

 Description   

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.



 Comments   
Comment by Githook User [ 11/Nov/19 ]

Author:

{'username': 'will62794', 'email': 'william.schultz@mongodb.com', 'name': 'William Schultz'}

Message: SERVER-43695 Add artificial sleeps to session_test.cpp to account for any transaction metrics clock discrepancy
Branch: v4.0
https://github.com/mongodb/mongo/commit/f8868f95e1a6ba84bc26ec6d556923bf343141fe

Generated at Thu Feb 08 05:03:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.