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

When using a nested shard key, a delete in a txn to a chunk that has moved is not throwing MigrationConflict



    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 4.9.0-alpha4
    • 5.0.0-rc0
    • Sharding
    • Fully Compatible
    • ALL
    • Sharding 2021-04-05, Sharding EMEA 2021-05-03, Sharding EMEA 2021-05-17


      After SERVER-55033 there is still one situation where OpObserverShardingImpl::shardObserveDeleteOp will not throw upon attempting to delete a document in a txn on a chunk that has moved since the atClusterTime. This situation happens when the collection has a nested shard key.

      For instance:

      OpObserverImpl::getDocumentKey() calls dotted_path_support::extractElementsBasedOnTemplate() and would return an object {"x.y": 10}.

      OpObserverShardingImpl::shardObserveDeleteOp() calls ShardKeyPattern::extractShardKeyFromDocThrows() which would fail to find the shard key because there is no field call "x" in the object {"x.y": 10}. There is only a field called "x.y".

      Possible solutions could be:
      a) Make shardObserveDeleteOp() receive the full document, so it can call extractShardKeyFromDoc() itself. This would likely cause a performance regression since we would need to save a copy of the full document in aboutToDelete().
      b) Make shardObserveDeleteOp() receive the shard key (without the _id, unless _id was part of the shard key pattern) so that it can skip calling extractShardKeyFromDoc*() itself. shardObserveDeleteOp() also needs to receive the _id separately so it can be given to MigrationChunkClonerSourceLegacy::onDeleteOp()
      c) Make OpObserverImpl::getDocumentKey set the shard key BSONObj as nested object (if the shard key was nested), instead of setting it as dot-notation.


        Issue Links



              jordi.serra-torrens@mongodb.com Jordi Serra Torrens
              jordi.serra-torrens@mongodb.com Jordi Serra Torrens
              0 Vote for this issue
              4 Start watching this issue