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:
- is depended on by
-
SERVER-33029 Support snapshot in cluster aggregate command
- Closed