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

API to get/set lastCommittedOpTime on Shard

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.7.3
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • Sharding 2018-02-12, Sharding 2018-02-26, Sharding 2018-03-12

      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/

            Assignee:
            jack.mulrow@mongodb.com Jack Mulrow
            Reporter:
            misha.tyulenev@mongodb.com Misha Tyulenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: