Details
-
Bug
-
Resolution: Works as Designed
-
Major - P3
-
None
-
4.0.3
-
None
-
ALL
-
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?