DBAtlas · Database operations atlas

112: WriteConflict (error code 112)

MongoDB

What does it mean?

A write conflict that occurs when two concurrent operations try to modify the same document(s). Because of optimistic concurrency control, WiredTiger rolls back one of the operations.

Why does it happen?

Highly concurrent writes to the same documents, conflicting updates during long-running transactions, heavy contention on a hot document.

How to fix it

Retry the operation; WriteConflict is usually transient and resolved by a retry (it is labeled TransientTransactionError). Keep transactions short and reduce the number of documents touched. Review the data model to reduce contention on the same document. Implement retries with exponential backoff in the application.

Open in DBAtlas →

More from this engine