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

Write conflict between batched inserts within transactions incorrectly throws DuplicateKey error

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.0-rc1, 4.1.1
    • Affects Version/s: None
    • Component/s: Storage
    • Labels:
      None
    • Fully Compatible
    • v4.0
    • Storage NYC 2018-06-04

      When running two concurrent, multi-document transactions that try to insert document sets that have a non-empty intersection, one of the transactions should fail with a WriteConflict, since both transactions try to write to the same document. Instead, it appears that a DuplicateKey error is instead being thrown. See attached repro.

      This is the transaction history being tested in the repro script:

      Start(T1), Start(T2), Insert(T2, [d1, d2]), Commit(T2), Insert(T1, [d2, d3]), Commit(T1)
      

      The first insert by T1 throws a DuplicateKey error. What is additionally odd is that the DuplicateKey error appears to be thrown on _id: 1, when we would expect the WriteConflict error to be thrown on _id: 2

      e.g.

      "errmsg" : "E11000 duplicate key error collection: test.transactions_write_conflicts index: _id_ dup key: { : 1.0 }",
      

            Assignee:
            milkie@mongodb.com Eric Milkie
            Reporter:
            william.schultz@mongodb.com William Schultz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: