Tasks for this ticket
Implementation
- Source everywhere getDestinedRecipient() is currently called. These places are where the ReshardingDonorWriteRouter should be constructed instead.
- OpObserverImpl::onInserts() should construct the ReshardingDonorWriteRouter once outside of the for loop. ReshardingDonorWriteRouter would have cached the ScopedCollectionFilter, ShardKeyPattern, and ChunkManager upon construction so calling ReshardingDonorWriteRouter::getDestinedRecipient() in a loop won't do extra work.
- repl::logInsertOps() should be changed to take a const ReshardingDonorWriteRouter& as an argument.
- All OpObserverImpl methods should use ReshardingDonorWriteRouter::getCollectionShardingState() to avoid getting the CollectionShardingState from the map a second time. Note that when the mongod isn't a shardsvr, ReshardingDonorWriteRouter::getCollectionShardingState() will return nullptr. This is acceptable because OpObserverShardingImpl won't have been registered for non-shardsvrs either and so the CollectionShardingState* pointer won't ever be dereferenced.
Code cleanup
- Remove the old free-standing getDestinedRecipient function.
- Change all unit tests that call the free-standing getDestinedRecipient function to instead create the ReshardingDonorWriteRouter object and call the corresponding function.
Unit tests
- We don't need any extra unit testing here. In the previous ticket, we swap over the getDestinedRecipient unit tests to use our new class, and replacing other calls to the function with your class will be sufficient testing coverage.
|