Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-33027

compute atClusterTime

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 3.7.3
    • None
    • Sharding
    • None
    • Fully Compatible
    • Sharding 2018-03-26

    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

      Attachments

        Activity

          People

            misha.tyulenev@mongodb.com Misha Tyulenev
            misha.tyulenev@mongodb.com Misha Tyulenev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: