[SERVER-55678] Use sleepUntil() rather than sleepFor() to schedule the ReshardingTxnCloners Created: 31/Mar/21  Updated: 29/Oct/23  Resolved: 06/May/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Task Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Jamie Anderson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Sharding 2021-05-03, Sharding 2021-05-17
Participants:
Story Points: 1

 Description   

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.


 Comments   
Comment by Githook User [ 05/May/21 ]

Author:

{'name': 'Jamie Anderson', 'email': 'jamie.anderson@mongodb.com', 'username': 'jandersongo'}

Message: SERVER-55678 Use sleepUntil() rather than sleepFor() to schedule the ReshardingTxnCloners
Branch: master
https://github.com/mongodb/mongo/commit/7baccddd62e581aa69b1e8d2f59ea3f26e5d8ff0

Generated at Thu Feb 08 05:37:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.