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

Replace getDestinedRecipient() in the code-base with calls into the ReshardingDonorWriteRouter object

    • Sharding 2021-09-20, Sharding 2021-10-04
    • 0
    • 1

      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.

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            blake.oler@mongodb.com Blake Oler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: