week 10

10.3 Concurrency Problems

When multiple transactions execute simultaneously without proper control, several problems can occur:

 

Concurrency Problem

Description and Example

Lost Update

Two transactions read the same data and both update it, but one update overwrites the other. E.g., two bank tellers simultaneously process deposits to the same account — one deposit is lost.

Dirty Read

Transaction T2 reads data written by T1 before T1 commits. If T1 rolls back, T2 has read invalid data. E.g., T2 reads a balance that T1 just updated but then rolled back — T2 acts on a 'phantom' value.

Non-Repeatable Read

T1 reads a value, T2 updates it and commits, T1 reads it again and gets a different value. E.g., a report reads an account balance, another transaction changes it, the report reads it again — inconsistent report.

Phantom Read

T1 executes a query returning a set of rows, T2 inserts/deletes rows matching T1's criteria, T1 repeats the query and gets different rows. E.g., counting active loans — a new loan is added mid-count.