SQLSTATE 40001Severity highLab verified

Incident brief

Could not serialize access due to concurrent update

The REPEATABLE READ concurrent-update form of SQLSTATE 40001: a REPEATABLE READ transaction attempted to update a row that a concurrently committed transaction had already changed. This page scopes to that exact form, the one reproduced in the lab below, not the general SERIALIZABLE case.

What lands in your log

ERROR: could not serialize access due to concurrent update

Reproduced on PostgreSQL 16.14Verified 2026-07-14 (Docker lab, PostgreSQL 16.14)Verified against PostgreSQL 16.14 in an isolated lab environment

In 10 seconds

What triggers it
Open session A and start a REPEATABLE READ transaction.
Fix
Rollback and retry the unit of work.
Proof
Reproduced on PostgreSQL 16.14 → Session A's transaction was cancelled and rolled back, no data change from session A. Session B's update had already committed successfully before session A's failure.

Fix

What to do right now

Application-level steps for this error.

  • Rollback and retry the unit of work.
  • Apply exponential backoff in the application layer.
  • Shorten the transaction so contention windows shrink.
Fix SQL
-- application strategy
BEGIN ISOLATION LEVEL REPEATABLE READ;
UPDATE accounts SET balance = balance + 100 WHERE id = 1;
COMMIT;
-- if this raises 40001: ROLLBACK, then retry the whole transaction
-- from the beginning with bounded exponential backoff

Connected

Everything this error touches

Every page this SQLSTATE connects to: the concept that explains it, the runbooks that fix it, the parameters you tune to prevent it, and the sibling errors it travels with. All real cross-references. Jump straight in, or open the full interactive map.

Open in the interactive map →

Verification

PG 16.14
Last verified
2026-07-14 (Docker lab, PostgreSQL 16.14)
Verification scope
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed
ShareLinkedInX

Went further?

Pro unlocks the second lab proof

Free page stops the bleeding. Pro adds the operational test, SQLSTATE audit, and deeper evidence, same error, more certainty.

FollowSubstackLinkedInnew errors · lab notes · hiring loops