Problems in Concurrency Control
Problems in concurrency control are the failures that occur when concurrent transactions run without adequate control. A dirty read reads another transaction's uncommitted data, a lost update happens when two transactions write based on the same stale read and one overwrites the other, and an unrepeatable read returns different values for the same row within one transaction.
When multiple transactions run concurrently without adequate concurrency control, several specific, well-documented problems can occur. Knowing these by name, and recognizing them concretely, is what lets you reason about whether a given isolation level or locking scheme actually protects against the failure mode you care about.
Dirty read
A transaction reads data that another transaction has written but not yet committed. If that other transaction later rolls back, the first transaction has now acted on data that never actually existed as far as the database is concerned.
T1: UPDATE accounts SET balance = 1000 WHERE id = 1; -- not committed yet
T2: SELECT balance FROM accounts WHERE id = 1; -- reads 1000, a dirty read
T1: ROLLBACK; -- balance reverts, was never really 1000
T2 made a decision based on a value that, from the database's perspective, never actually existed.
Lost update
Two transactions both read the same value, then both write a new value based on that same stale read, and one overwrites the other's change entirely.
T1: reads stock = 10
T2: reads stock = 10
T1: writes stock = 10 - 3 = 7 -- intends to reserve 3 units
T2: writes stock = 10 - 5 = 5 -- intends to reserve 5 units, overwrites T1's result
The final stock = 5 reflects only T2's change. T1's reservation of 3 units is silently lost, even though T1's transaction reported success.
Unrepeatable read
A transaction reads the same row twice, and gets two different values, because another transaction committed a change to that row in between the two reads.
T1: SELECT balance FROM accounts WHERE id = 1; -- reads 100
T2: UPDATE accounts SET balance = 150 WHERE id = 1; T2: COMMIT;
T1: SELECT balance FROM accounts WHERE id = 1; -- reads 150, different from before
If T1's logic assumed the value would stay the same for the duration of its own transaction (a common, reasonable assumption), this can produce a genuinely wrong result.
Where this matters in real systems
Choosing an isolation level is really choosing which of these specific problems you're willing to accept in exchange for better performance. Read Committed prevents dirty reads but still allows unrepeatable reads and lost updates in some cases; Repeatable Read additionally prevents unrepeatable reads; Serializable prevents all of them. Real application code, especially anything doing a read-then-write based on that read (like reserving inventory), needs to actively consider which of these problems its chosen isolation level still permits.
What interviewers actually ask about concurrency control problems
- "What is a dirty read?" Reading another transaction's uncommitted changes, which might later be rolled back and never actually take effect.
- "What is a lost update, concretely?" Two transactions read the same value, both compute a new value from it, and one overwrites the other's result, silently losing one of the updates.
- "What is an unrepeatable read?" Reading the same row twice within one transaction and getting different values because another transaction committed a change in between.
- "Which isolation level would you need to prevent lost updates entirely?" Depends on the specific case, but generally Repeatable Read or Serializable, or explicit locking (like SELECT FOR UPDATE), are needed to prevent the read-then-write race that causes lost updates.
Key takeaways
- A dirty read means reading another transaction's uncommitted, potentially-to-be-rolled-back changes.
- A lost update means two transactions both write based on the same stale read, and one silently overwrites the other.
- An unrepeatable read means the same row returns different values on two reads within one transaction.
- The isolation level chosen determines which of these specific problems are actually prevented.
More in Transaction Processing
Browse all DBMS topics
Log in to save which topics you've read across every subject.
Frequently asked questions
What is a dirty read?
Reading another transaction's uncommitted changes, which might later be rolled back and never actually take effect.
What is a lost update, concretely?
Two transactions read the same value, both compute a new value from it, and one overwrites the other's result, silently losing one of the updates.
What is an unrepeatable read?
Reading the same row twice within one transaction and getting different values because another transaction committed a change in between.
Which isolation level would you need to prevent lost updates entirely?
Depends on the specific case, but generally Repeatable Read or Serializable, or explicit locking (like SELECT FOR UPDATE), are needed to prevent the read-then-write race that causes lost updates.