Error in runInTransaction:MongoServerError: WiredTigerRecordStore::insertRecord

getting this error while using multi document transaction can some one suggest how to resolve this issue

error: Error in runInTransaction:MongoServerError: WiredTigerRecordStore::insertRecord :: caused by :: WriteConflict error: this operation conflicted with another operation. Please retry your operation or multi-document transaction. {"label":"runInTransaction","timestamp":"2023-10-03 06:12:20 PM"}

Hi @biranjan_soni1,

Welcome to the MongoDB Community :sparkles:

The issue you are facing seems to be related to MongoDB’s document-level concurrency control. MongoDB uses optimistic concurrency control to ensure consistency in its transactions.

As you know, if two or more transactions attempt to modify the same document concurrently, MongoDB will throw a WriteConflict error, indicating that one or more transactions failed due to conflicts.

To understand more about your error, could you please share the following:

  • The full error stack trace you’re seeing? Is there any more information other than just “write conflict error”?
  • What MongoDB version you are using?
  • And the code snippet that you are executing.

Meanwhile, please go through this link to read about In-progress Transactions and Write Conflicts.


Hi@ Kushagra_Kesav. this is the insert record operation. it’s impossible that two or more transactions attempt to modify the same document concurrently.