[SERVER-33027] compute atClusterTime Created: 30/Jan/18  Updated: 29/Oct/23  Resolved: 14/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: Misha Tyulenev
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
Duplicate
is duplicated by SERVER-34074 Make a helper function to compute atC... Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 2018-03-26
Participants:

 Description   

Summary:

Given a list of targeted shard ids, return the logical time to be used as the atClusterTime value that will be included in the commands sent to all the shards. This will be the max lastCommittedOpTimes of the given shards, found by looking up each shard in the shard registry and then calling getLastCommittedOpTime(). Since this logic will be shared by read commands, it should be put into a file of helper functions, like src/mongo/s/commands_helpers.cpp.

Details:

LogicalTime computeAtClusterTime(OperationContext* opCtx, std::set<ShardId> shardIds) {
    invariant(shardIds.size() > 0);
 
    auto shardRegistry = Grid::get(opCtx)->shardRegistry();
    LogicalTime highestTime;
    for (const auto& shardId : shardIds) {
        auto lastCommittedOpTime =
            shardRegistry->getShardNoReload(shardId)->getLastCommittedOpTime();
        if (lastCommittedOpTime > highestTime) {
            highestTime = lastCommittedOpTime;
        }
    }
 
    return highestTime;
}

Open Questions:

  • What to return if given an empty list of shard ids?
    • it doesn't seem like this is possible, so invariant?

UnitTests

  • Mock a shardRegistry with several shards, set lastCommittedOpTimes on each shard, and verify that computeAtClusterTime returns the highest time.

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



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

Author:

{'email': 'misha@mongodb.com', 'name': 'Misha Tyulenev', 'username': 'mikety'}

Message: SERVER-33027 add computeAtClusterTime helper
Branch: master
https://github.com/mongodb/mongo/commit/1481f7068376b464eb6dff954f004b023d3bbbd5

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