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

Use sleepUntil() rather than sleepFor() to schedule the ReshardingTxnCloners

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.0-rc0
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • Sharding 2021-05-03, Sharding 2021-05-17
    • 1

      Using TaskExecutor::sleepFor() has the downside that if there's a primary failover, then a whole new minimumOperationDuration period must elapse before the ReshardingTxnCloners begin again. It would be more efficient to write down the Date_t of when the ReshardingTxnCloners can begin as part of the transition to RecipientStateEnum::kCreatingCollection and use sleepUtil() instead. The Date_t can be calculated from calling TaskExecutor::now() + RecipientStateMachine::_minimumOperationDuration.

      for (const auto& txnCloner : _txnCloners) {
          txnClonerFutures.emplace_back(
              executor->sleepFor(minimumOperationDuration, cancelToken)
                  .then([executor, cleanupExecutor, cancelToken, txnCloner = txnCloner.get()] {
                      return txnCloner->run(executor, cleanupExecutor, cancelToken);
                  })
                  .share());
      }
      

      https://github.com/mongodb/mongo/blob/ead95fd4d389d1e370798cfd9ba098ac27dafd2c/src/mongo/db/s/resharding/resharding_data_replication.cpp#L442

      Work on this ticket will also involve

      1. Adding a new, optional field to the ReshardingRecipientDocument IDL struct of {type: date, optional: true}.
      2. Adding a new, boost::optional<Date_t> _startConfigTxnCloneAt member to RecipientStateMachine and initializing it as ReshardingRecipientDocument::getStartConfigTxnCloneAt() in the constructor and assigning it the value calculated from TaskExecutor::now() + RecipientStateMachine::_minimumOperationDuration following the transition to RecipientStateEnum::kCreatingCollection.

            Assignee:
            jamie.anderson@mongodb.com Jamie Anderson
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: