// troubleshooting guide · cockroachdb
CockroachDB 'restart transaction' Error (40001) Fix
- Status
- Ongoing
- platforms:
- Self-hosted and CockroachDB Cloud
- updated:
- November 15, 2026
- reports:
- 4
- Method
- how we research
RUNBOOK · cockroachdb/restart-transaction-error4 FIXES
// quick answer
CockroachDB returns SQLSTATE 40001 'restart transaction' when concurrent transactions conflict under SERIALIZABLE isolation. Add a client-side retry loop with backoff, batch statements, and reduce contention.
Most likely fix: Add a client-side retry loop
How to fix it
// try these in order, the most common fix is first
FIX 1Add a client-side retry loop
- 01Catch errors with SQLSTATE 40001 (message contains 'restart transaction')
- 02Retry the whole transaction with exponential backoff and a max_retries limit
- 03Test it by enabling the inject_retry_errors_enabled session setting
Did this fix it?FIX 2Let CockroachDB retry for you
- 01Send all statements of the transaction in one batch so automatic retry can work
- 02Keep result sets under 16KB and avoid reading large results mid-transaction
- 03Keep transactions short
Did this fix it?FIX 3Reduce contention
- 01Find hot rows on the DB Console Insights / Transactions pages
- 02Avoid sequential keys; use UUIDs or hash-sharded indexes
- 03Split counters across several rows
Did this fix it?FIX 4Try READ COMMITTED
- 01Enable READ COMMITTED isolation where your app tolerates it
- 02READ COMMITTED transactions do not return serialization errors that need client-side handling
Did this fix it?
Symptoms
ERROR: restart transaction: TransactionRetryWithProtoRefreshError; SQLSTATE 40001; transactions fail under load but work alone.
Why it happens
- C-01Concurrent writes to the same rows (hot keys) under SERIALIZABLE isolation
- C-02Multi-statement transactions that take several round trips and cannot be auto-retried
- C-03Result sets over 16KB sent before the transaction finished
- C-04Long-running transactions that touch many rows
- C-05No retry logic in the application or ORM
// this guide also covers
- cockroachdb restart transaction
- cockroachdb 40001
- TransactionRetryWithProtoRefreshError
- cockroachdb serialization failure
- cockroachdb transaction retry error
Still not working?
If CockroachDB keeps failing, you're not alone. See every CockroachDB problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to usThe same problem in other apps
All not loading, error messages & connection guides →
PlanetScale Prisma Connection Errors (PlanetScale)
Other CockroachDB errors
- CockroachDB Cluster Throttled: License Expired or No Telemetry
- Why Is CockroachDB Slow? Slow Query Fixes
- CockroachDB Connection Refused / Cannot Connect Fix
- CockroachDB Node Down or Cluster Unavailable: Fix
- CockroachDB High Memory, CPU or OOM Crash Fix
- CockroachDB 'Not Supported' / Postgres Compatibility Errors Fix
- CockroachDB Cloud Bill Too High: How to Cut Costs
- How to Cancel or Downgrade CockroachDB Cloud