[SERVER-47897] CurOp should use monotonic clock source for duration measurements Created: 01/May/20  Updated: 29/Oct/23  Resolved: 11/Jun/20

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

Type: Bug Priority: Major - P3
Reporter: Nicholas Zolnierz Assignee: James Wahlin
Resolution: Fixed Votes: 0
Labels: greenerbuild, qopt-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-48078 Remove OpDebug invariant that relies ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:
Linked BF Score: 16

 Description   

In several spots, curOp uses curTimeMicros64 which delegates to gettimeofday() on linux. This is not guaranteed to be monotonically increasing and can lead to incorrect reporting for metrics.



 Comments   
Comment by Githook User [ 10/Jun/20 ]

Author:

{'name': 'James Wahlin', 'email': 'james@mongodb.com', 'username': 'jameswahlin'}

Message: SERVER-47897 CurOp should use monotonic clock source for duration measurements
Branch: master
https://github.com/mongodb/mongo/commit/af0d84cb6eaab138cae7ed690ca84b32a21eee6c

Comment by James Wahlin [ 11/May/20 ]

As part of this work, we should consider adding back this invariant which will be removed under SERVER-48078.

Comment by James Wahlin [ 08/May/20 ]

Using SystemTickSource appears to be the right solution for duration measurement. It uses a monotonic clock to record points in time and is unaffected by NTP time adjustments so safer for comparison. It can provide the microsecond granularity that the current curTimeMicros64() call provides.

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