Describe the lost-update problem and how locking solves it.
Describe the lost-update problem and how locking solves it.
Answer
Two transactions read the same value, each updates it independently, and the second write overwrites the first — the first update is lost. Locking solves it by making the first transaction take an exclusive lock before reading; the second is blocked until the first commits, then reads the updated value.
It is the canonical reason concurrency control exists: an unguarded read-then-write race silently erases an update.