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

XMLWordPrintableJSON

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

      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
              Reporter:
              Max Hirschhorn
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: