[SERVER-27786] Implement computeOperationTimeForRead Created: 23/Jan/17  Updated: 05/Apr/17  Resolved: 23/Mar/17

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

Type: Task Priority: Major - P3
Reporter: Misha Tyulenev Assignee: Jack Mulrow
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Sharding 2017-03-06, Sharding 2017-03-27
Participants:

 Description   

Currently the opeartionTime computed in Command::run() is a pessimization that returns the current clusterTime as an operationTime and that may make the following client's requests with readAfterClusterTime set to this value wait when it should not to.
The correct implementation should return the operationTime that is specific for the operation time and read/writeConcern.

for the write operation:
should be

repl::ReplClientInfo::forClient(opCtx->getClient()).getLastOp().getTimestamp());

read with readConcern level majority: operationTime is the committed LogicalTime_LOG.

auto replCoord = ReplicationCoordinator::get(opCtx);
auto lastAppliedOpTime = replCoord->getLastCommittidOpTime();

read with readConcern level local: operationTime is the local LogicalTime_LOG.

auto replCoord = ReplicationCoordinator::get(opCtx);
auto lastAppliedOpTime = replCoord->getMyLastAppliedOpTime();

The last question is how to differ "read" vs "write" operation:
so if the ReplClientInfo getLastOp() called before and after the command is run are same its considered a "read" otherwise its a write.
The change in Command::run should
a) get the startOperationTime (its already done)
b) extract from the read or write concern.
majority = readConcern:level majority or writeConcern:w majority
everything else is considered local. I think its ok to count w:0 as local as well.
c) once the operation is finished pass the computed level and the startOperationTime to implement the logic specified above.



 Comments   
Comment by Githook User [ 23/Mar/17 ]

Author:

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

Message: SERVER-27786 Implement _computeOperationTime
Branch: master
https://github.com/mongodb/mongo/commit/5a6383e5d1028c8688e08bf5caabcfaadc5ee715

Comment by Randolph Tan [ 16/Mar/17 ]

looks good to me as well

Comment by Spencer Brody (Inactive) [ 16/Mar/17 ]

Plan outlined above lgtm

Comment by Misha Tyulenev [ 16/Mar/17 ]

spencer renctan Please confirm that you can review the CR once its ready and please ack the proposed solution.

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