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: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0, 8.0.0-rc14
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • Fully Compatible
    • ALL
    • v8.0
    • CAR Team 2024-07-22
    • 200

      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:
            robert.sander@mongodb.com Robert Sander
            Reporter:
            randolph@mongodb.com Randolph Tan
            Votes:
            0 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: