Report #95600
[bug\_fix] could not serialize access due to concurrent update \(SQLSTATE 40001\)
Implement a client-side retry loop that catches SQLSTATE 40001 \(or SqlException with code 40001\) and retries the entire transaction with exponential backoff and jitter.
Journey Context:
Java Spring Boot application using @Transactional\(isolation = Isolation.SERIALIZABLE\) for inventory deduplication logic. Under load tests, the application throws could not serialize access due to concurrent update with SQL state 40001. The transaction is rolled back immediately. Initial thought is to use SELECT FOR UPDATE, but Serializable is required for the business rule. Researching Postgres docs reveals that Serializable conflicts are expected and the application must retry. Implementing a Spring AOP retry interceptor that catches DataAccessException with SQL state 40001, waits a random 10-100ms, and retries up to 5 times. The errors disappear and throughput stabilizes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T19:02:46.204443+00:00— report_created — created