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

Transaction eagerly locks document causing WriteConflict

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • 4.0.3
    • None
    • Concurrency
    • 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...

    Description

      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?

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: