[SERVER-34843] Mongod can return operationTime greater than $clusterTime Created: 04/May/18  Updated: 29/Oct/23  Resolved: 14/May/18

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 3.6.7, 4.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Jack Mulrow Assignee: Jack Mulrow
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Duplicate
is duplicated by SERVER-33177 Inconsistent handling of operation ti... Closed
Problem/Incident
causes SERVER-35377 Operations on new clients get latest ... Closed
is caused by SERVER-33585 Do not return $clusterTime when no ke... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Sprint: Sharding 2018-05-21
Participants:
Linked BF Score: 15

 Description   

There is a race in the way mongod computes $clusterTime and operationTime. Before returning a response, mongod gets the latest cluster time from the LogicalClock and adds it to the request as $clusterTime (in appendReplyMetadata, called for successful commands here). Then, if a non null $clusterTime was computed, operationTime is computed by asking for the latest opTime on the client for writes, or the opTime of the last applied or committed write, for local and majority reads respectively. There is no synchronization that prevents the last applied or committed opTimes from advancing beyond the previously computed $clusterTime, allowing operationTime to be larger than $clusterTime in the response.

 A straightforward way to fix this could be to just compute operationTime before $clusterTime, because $clusterTime is always allowed to be greater than operationTime.

 



 Comments   
Comment by Githook User [ 01/Aug/18 ]

Author:

{'name': 'Jack Mulrow', 'email': 'jack.mulrow@mongodb.com', 'username': 'jsmulrow'}

Message: SERVER-34843 Compute operationTime before $clusterTime

(cherry picked from commit 9482d5a32e100ce7f939ea5789b1862fc98e9924)
Branch: v3.6
https://github.com/mongodb/mongo/commit/428868a14b3017b9b97325be4290f7b70b7396f9

Comment by Jack Mulrow [ 14/May/18 ]

The race this fixed was caused by SERVER-33585, which was backported to the 3.6 branch, so I'm requesting a 3.6 backport for this as well.

Comment by Githook User [ 14/May/18 ]

Author:

{'name': 'Jack Mulrow', 'email': 'jack.mulrow@mongodb.com', 'username': 'jsmulrow'}

Message: SERVER-34843 Compute operationTime before $clusterTime
Branch: master
https://github.com/mongodb/mongo/commit/9482d5a32e100ce7f939ea5789b1862fc98e9924

Generated at Thu Feb 08 04:38:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.