Dirty Read, Non-Repeatable Read & Phantom Read
Reviewed by Gurusankar M. · Updated Aug 24, 2026
Short Answer
Dirty read = seeing another txn's uncommitted data (prevented by READ COMMITTED). Non-repeatable read = same row returns different values within a txn (prevented by REPEATABLE READ). Phantom read = new rows appear for a re-run range query (prevented by SERIALIZABLE).
On this page
Concept Made Simple
Coffee Chat Question
“Dirty read, non-repeatable read and phantom read — what are they and how do you prevent each?”
Remember It Faster
Mind Map Answer
- Dirty read
- reads uncommitted data → READ COMMITTED
- Non-repeatable
- row value changes → REPEATABLE READ
- Phantom
- new rows in range → SERIALIZABLE
Think Beyond the Expected
What If?
A balance check then debit double-spends under load — which anomaly, and the fix?
A read-then-write race (often a phantom/non-repeatable issue). Fix with SELECT ... FOR UPDATE to lock the row during the transaction, or optimistic locking with a version check, rather than just raising the global isolation level.
Real World
These anomalies underlie real money bugs (double-spend, oversell). Engineers pick the isolation level — or explicit locking — that blocks the specific anomaly their invariant needs.
Interviewer's Expectation
Keywords they're listening for:
- define all three
- which level prevents which
- read-then-write race
- FOR UPDATE / optimistic locking
- MVCC nuance
Common Mistakes
- Confusing non-repeatable read with phantom read
- Relying on app logic for read-then-write safety
- Assuming default isolation prevents all anomalies
Best Practices
- Lock or version read-then-write critical sections
- Match isolation to the invariant you must protect
- Test concurrency paths under load
Follow-up Questions
- How does MVCC handle non-repeatable reads without locks?
- What's a write skew and which level prevents it?
- When do you reach for SELECT FOR UPDATE?
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: Transactions (SQL) Interview question: "Dirty read, non-repeatable read and phantom read — what are they and how do you prevent each?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair