[SERVER-33016] API to get/set lastCommittedOpTime on Shard Created: 30/Jan/18  Updated: 29/Oct/23  Resolved: 06/Mar/18

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

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

Issue Links:
Depends
is depended on by SERVER-33029 Support snapshot in cluster aggregate... Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 2018-02-12, Sharding 2018-02-26, Sharding 2018-03-12
Participants:

 Description   

Summary:

Mongos needs to track the highest lastCommittedOpTime it's seen per shard, so new logic needs to be added to the Shard interface.

Description:

ShardRemote will get a new private field LogicalTime _lastCommittedOpTime that will be updated / accessed through new methods void updateLastCommittedOpTime(LogicalTime lastCommittedOpTime) and LogicalTime getLastCommittedOpTime(). These methods will be declared in src/mongo/s/client/shard.h, but only implemented in ShardRemote, containing MONGO_UNREACHABLE in ShardLocal. This new field will need to be mutex protected, and we will only store the new time in updateLastCommittedOpTime if the new time is greater than the currently stored one (it's possible a secondary returns a lastCommittedOpTime lower than one returned from an earlier command on a primary or farther ahead secondary).

void ShardRemote::updateLastCommittedOpTime(LogicalTime time) {
     stdx::lock_guard<stdx::mutex> lk(_lastCommittedOpTimeMutex);
     if (lastCommittedOpTime > _lastCommittedOpTime) {
         _lastCommittedOpTime = lastCommittedOpTime;
     }
}
 
LogicalTime ShardRemote::getLastCommittedOpTime() {
    stdx::lock_guard<stdx::mutex> lk(_lastCommittedOpTimeMutex);
    return _lastCommittedOpTime;
}
 
mutable stdx::mutex _lastCommittedOpTimeMutex;
LogicalTime _lastCommittedOpTime;

Open Questions:

POC: https://mongodbcr.appspot.com/188010001/



 Comments   
Comment by Githook User [ 06/Mar/18 ]

Author:

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

Message: SERVER-33016 API to get/set lastCommittedOpTime on Shard
Branch: master
https://github.com/mongodb/mongo/commit/e1a634430c8087706c855f2e29944228c74cbaad

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