Skip to content
Back to the playbook

Diagnosing and handling Postgres serialization failures (40001)

PostgreSQLrevision 1

Diagnostic tree

  1. In progressYou're seeing SQLSTATE 40001A transaction failed with `could not serialize access due to concurrent update`, SQLSTATE 40001. This only happens under REPEATABLE READ or SERIALIZABLE isolation — Postgres detected that letting both this transaction and a concurrent one commit could not have arisen from any serial execution, so it aborted one of them.
View the whole map (7 more steps)
  • Confirm the transaction is running above READ COMMITTED
  • This is Postgres's conflict detection working as designed
  • 40001 without elevated isolation is unusual
  • Retry the whole transaction on 40001
  • Confirm the retry logic is actually working
  • Resolved
  • Still surfacing to users

What to test

You're seeing SQLSTATE 40001

A transaction failed with `could not serialize access due to concurrent update`, SQLSTATE 40001. This only happens under REPEATABLE READ or SERIALIZABLE isolation — Postgres detected that letting both this transaction and a concurrent one commit could not have arisen from any serial execution, so it aborted one of them.

What happened?