Read and Write Conflicts
What you'll learn: You'll discover the three classic isolation problems—dirty reads, non-repeatable reads, and phantom reads—that arise when concurrent transactions interfere with each other.
The Problem
When multiple transactions run simultaneously without proper isolation, they can step on each other's toes. Even though we've learned that isolation aims to keep transactions independent, understanding what goes wrong without it helps us appreciate why isolation levels matter.
Three Classic Conflicts
Dirty Reads
A dirty read occurs when Transaction A reads data that Transaction B has modified but not yet committed. If B rolls back, A just read data that "never really existed."
Analogy: You check your friend's draft essay and quote from it in your paper. Then your friend deletes that entire paragraph before submitting. Your quote references something that was never finalized.
Non-Repeatable Reads
A non-repeatable read happens when Transaction A reads the same row twice, but gets different values because Transaction B modified and committed that row in between A's two reads.
Analogy: You check a product's price at 2 PM (45 because someone updated the price while you were browsing.
Phantom Reads
A phantom read occurs when Transaction A runs the same query twice, but the second time sees additional rows (or fewer rows) because Transaction B inserted or deleted rows that match A's query criteria.
Analogy: You count all books on a shelf (finding 10), walk around the library, return to count again, and now there are 12 books—someone shelved new ones while you were gone.
Why These Matter
These conflicts violate the independence we expect from isolated transactions, potentially causing incorrect calculations, broken business rules, or inconsistent application state.
Key Takeaway: Without proper isolation, concurrent transactions can experience dirty reads (uncommitted data), non-repeatable reads (changed values), and phantom reads (changed result sets), breaking the assumption that transactions execute independently.