2019-05-13T19:01:30.473+0700 I COMMAND [conn10179] command admin.$cmd appName: "XXX" command: commitTransaction { commitTransaction: 1, lsid: { id: UUID("4d66cc5b-70ff-4f08-9eae-d281b87b59c4") }, txnNumber: 61576, autocommit: false, $db: "admin" } numYields:0 ok:0 errMsg:"WriteConflict" errName:WriteConflict errCode:112 reslen:153 locks:{ Global: {acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 2 } }, Collection: { acquireCount: { w: 2 } } } protocol:op_msg 0ms
During load test, I found "WriteConflict" error on commit transaction. Pseudocode is given roughly below:
- create session
- start transaction
- insert
- POST data via rest API
- if success, commit transaction, otherwise abort
Language: golang
Mongo driver: go.mongodb.org/mongo-driver v1.0.0
I would like to know that
Why WriteConflict does occur during commit transaction. I do only insert one document(new) per transaction. IMOP document cannot be locked. Why WriteConflict?
How to fix it?