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

moveCollection can hit a duplicate key error during applying phase

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Cluster Scalability
    • ALL
    • v8.0
    • 0

      if there is a unique index on field other than _id.

      This is because the resharding oplog batch applier partitions a batch of oplog to apply by _id of the document to each worker thread. This creates a scenario where ops are executed on a different order compared to the source collection, potentially introducing a uniqueness violation that never occurred in the source collection.

      Some examples (unique on field x):
      op0: insert _id: 1, x: 1
      op1: delete _id: 1
      op2: insert _id: 2, x: 1

      Example order that cauases a uniquness violation: op0 -> op2 -> op1

      Another example (unique on field x):
      op0: insert _id: 1, x: 1
      op1: insert _id: 2, x: 2
      op2: update _id: 2, set x = 3
      op3: update _id: 1, set x = 2

      Example order that causes a uniquness violation: op0 -> op1 -> op3 -> op2

            Assignee:
            Unassigned Unassigned
            Reporter:
            randolph@mongodb.com Randolph Tan
            Votes:
            0 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated: