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

Concurrent upserts to the same non-existing document can result in duplicate key error

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.8.0-rc5
    • Component/s: Concurrency, Write Ops
    • None
    • Environment:
      2.8.0-rc5, wiredTiger storage engine only
    • ALL
    • Hide

      Run the Java code from this gist: https://gist.github.com/anonymous/5221f3025b549a708299

      Expected result:

      One thread will "win" and be the one to insert the document. The rest will see the insert and just update the existing document.

      Actual result:

      Depending on timing, there are 0-4 exceptions thrown indicating a duplicate key error.

      Show
      Run the Java code from this gist: https://gist.github.com/anonymous/5221f3025b549a708299 Expected result: One thread will "win" and be the one to insert the document. The rest will see the insert and just update the existing document. Actual result: Depending on timing, there are 0-4 exceptions thrown indicating a duplicate key error.

      A test program that starts five threads, each repeatedly upserting a document with the same _id to a collection that doesn't initially contain a document with that _id, will encounter duplicate key errors on the first attempt from 0-4 of the five threads, depending on timing.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: