Inconsistent results inside a transaction: non-repeatable and phantom reads (isolation level)
Two reads in the same transaction see different data because another transaction committed in between.
non-repeatable readphantom readlost update SQLREAD COMMITTED isolation anomalyserialization failure could not serialize access Meaning
READ COMMITTED allows non-repeatable and phantom reads; REPEATABLE READ and SERIALIZABLE prevent more anomalies at the cost of locks/retries. Pick the isolation level per need, use SELECT ... FOR UPDATE for read-modify-write, and be ready to retry serialization failures.
Common causes
- Default READ COMMITTED isolation
- Read-then-write race (lost update)
- Phantom rows appearing in range queries
- No row locking on read-modify-write
- Long-running reports on changing data
⚡ Quick fix
- Use
SELECT ... FOR UPDATEwhere you modify what you read - Raise the isolation level where needed and retry on conflict
- Keep transactions short
Detailed fix by platform
SQL
- sql
BEGIN; SELECT balance FROM accounts WHERE id = 1 FOR UPDATE; UPDATE accounts SET balance = balance - 100 WHERE id = 1; COMMIT;
How to diagnose
- Isolation — Which level?
- Lock — On read?
- Retry — Implemented?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 1205 SQL Server Msg 1205: Transaction was deadlocked on lock resources and has been chosen as the deadlock victim
- 1213 MySQL ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction
- 25P02 ERROR: current transaction is aborted, commands ignored until end of transaction block
Most viewed in SQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026