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

Document or possibly mitigate scenario where shards end up with different prepareUnique and unique index settings

    • Fully Compatible
    • v6.1, v6.0
    • Execution Team 2022-10-17, Execution Team 2022-10-31, Execution Team 2022-11-14

      This isn't a new inconsistency for indexes on a sharded collection but a new way for an inconsistency to manifest. For comparison, the createIndexes command broadcasted by mongos to all shards which own a chunk for the sharded collection can fail on one shard and succeed on another (same for the dropIndexes command). The main consequence is it can lead to chunk migrations failing with a DuplicateKey exception because shards are enforcing different index constraints from each other.

      Let's say there is a collection sharded on {x: 1} which lives on 2 shards and has a non-unique index {x: 1, y: 1}.

      1. The collMod command is run with {prepareUnique: true} for the {x: 1, y: 1} index to start preventing new duplicate (x, y) pairs from being inserted or updated. This step succeeds on both shards.
      2. The collMod command is run with {unique: true} for the {x: 1, y: 1} index to verify there are no existing duplicate (x, y) pairs. This step succeeds on one of the shards and fails on the other shard.

      A chunk migration between the 2 shards may fail with a DuplicateKey error due to the (x, y) pairs not being globally unique across all shards. Removing the duplicates and retrying the collMod command is run with {unique: true} may not be practical. However the cluster operator is also left without a means of converting the {x: 1, y: 1} index back to being a non-unique index.

            Assignee:
            yuhong.zhang@mongodb.com Yuhong Zhang
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: