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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 4.9.0-alpha4
    • Fix Version/s: 5.0.0-rc0
    • Component/s: Sharding
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Sharding 2021-04-05, Sharding EMEA 2021-05-03, Sharding EMEA 2021-05-17

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jordi.serra-torrens Jordi Serra Torrens
              Reporter:
              jordi.serra-torrens Jordi Serra Torrens
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: