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

Transaction eagerly locks document causing WriteConflict

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.0.3
    • Component/s: Concurrency
    • Labels:
      None
    • ALL
    • Hide

      Run attached file.

      Expected, some-event state updated to right

      Actual, output

      -4
      -3
      -2
      -1
      0
      1
      2
      3
      { MongoError: WriteConflict... 
      Show
      Run attached file. Expected, some-event state updated to right Actual, output -4 -3 -2 -1 0 1 2 3 { MongoError: WriteConflict...

      mongodb server 4.0.3
      npm client mongodb 3.3.1
       
      When two sessions are trying to update the same document, if the first session updates the document, attempt by the second session to update the document will fail with WriteConflict, even if the first session has not committed the transaction yet.
       
      Attached is code sample which reproduces this case. The sample code prints numbers so you can see which line of code causes the WriteConflict.
       
      I believe this is a bug because imagine if the aliceSession will throw an error before ever committing the transaction. Why should bobSession be punished with a WriteConfilct when aliceSession will never commit?

            Assignee:
            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            Reporter:
            ronald@battlefy.com Ronald Chen
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: