Concurrency Control in DBMS: Lost Updates, Locks and a Worked Schedule
See how two individually correct transactions can produce a wrong balance. Then repair the same schedule with strict two-phase locking and learn the usual exam traps.
KnowledgeGate Team
Exam prep & CS education

Two transactions can each be correct when run alone and still leave the database wrong when their reads and writes interleave. The difficult part is seeing exactly where that error enters a schedule. An account-balance schedule exposes the lost update, and strict two-phase locking repairs the same schedule. The key skills are naming common anomalies, reading lock notation and testing a short schedule instead of memorising definitions.
Concurrency control in DBMS: what it protects
A transaction is a logical unit of database work, such as withdrawing money or recording a sale. A schedule is the order in which the read, write and commit operations of one or more transactions execute.
In a serial schedule, one transaction finishes before the next begins. In a concurrent schedule, their operations interleave. That overlap can improve resource use, so concurrency itself is not the error. The danger is an uncontrolled conflict where different transactions touch the same item and at least one writes it.
Concurrency control aims to preserve isolation and produce a result equivalent to some correct serial order while still allowing useful overlap. Transactions & Concurrency Control in DBMS introduces ACID, schedules, serializability and precedence graphs. Concurrency Control in DBMS: Anomalies, Serializability, Locking and 2PL with Worked Examples connects the full chain through precedence graphs, timestamp ordering and recoverability. Here, one lost-update schedule is run twice: first without control, then under strict 2PL, so the lock-induced wait and corrected final value can be compared operation by operation.
Concurrency anomalies: four ways interleaving fails
An anomaly is the visible symptom of an unsafe interleaving. The value traces identify the failure in each anomaly.
Anomaly | What the second transaction sees | Small value trace |
|---|---|---|
Lost update | An old value, followed by its own write overwriting another update |
|
Dirty read | A value written but not committed by T1 | T1 changes |
Non-repeatable read | A different committed value on its second read | T1 reads stock |
Incorrect summary | A mixture of states from one transfer | Start |
A dirty read depends on another transaction's uncommitted change, which may later disappear on abort. A non-repeatable read observes two different committed values. Serializability, locking, timestamp ordering and multiversion methods are control ideas used to prevent or contain such symptoms.
Lost update schedule: compute the wrong answer
Let shared item A start at 1000. T1 withdraws 100, while T2 adds 50. If both read before either writes, T1 computes 1000 - 100 = 900 locally and T2 computes 1000 + 50 = 1050 locally.
Step | T1 | T2 | Database A |
|---|---|---|---|
1 |
|
| |
2 |
|
| |
3 | Compute local |
| |
4 | Compute local |
| |
5 |
|
| |
6 |
|
| |
7 | Commit | Commit |
|
T2's final write replaces 900 with 1050, so T1's withdrawal is lost. Check that result against both possible serial orders:
T1 then T2:
(1000 - 100) + 50 = 900 + 50 = 950.T2 then T1:
(1000 + 50) - 100 = 1050 - 100 = 950.
Both correct serial executions end at 950. The concurrent final value 1050 matches neither, so the schedule is not equivalent to either serial order.

Lock-based concurrency control: S, X and 2PL
A shared lock, written S(A), allows a transaction to read A. An exclusive lock, written X(A), is required to write A. Compatibility on the same data item is exact:
Lock already held | Requested S | Requested X |
|---|---|---|
S | Allowed | Not allowed |
X | Not allowed | Not allowed |
Basic two-phase locking, or 2PL, has an expanding phase in which locks are acquired and a shrinking phase in which locks are released. After the first unlock, that transaction may not acquire a new lock. Schedules produced under 2PL are conflict serializable, but 2PL can create deadlock.
Strict 2PL adds one rule: every exclusive lock is held until commit or abort. This stops another transaction from reading an uncommitted value protected by that lock, but it still does not make deadlock impossible.
Strict 2PL repair: make T2 wait
Reuse A = 1000, T1's withdrawal of 100 and T2's addition of 50. Strict 2PL changes the sequence as follows:
T1 obtains
X1(A), reads1000, computes1000 - 100 = 900, and writes900.T2 requests
X2(A). T1 still holds the exclusive lock, so T2 must wait.T1 commits and unlocks A.
T2 obtains
X2(A)and now reads the committed value900.T2 computes
900 + 50 = 950, writes950, commits and unlocks A.
The final value is 950, exactly matching serial order T1 then T2. Waiting is deliberate coordination, not a failed transaction. If T2 gets the lock first, it writes 1000 + 50 = 1050; T1 then reads that committed value and writes 1050 - 100 = 950. The alternate safe order reaches the same final state.

Concurrency control exam patterns and traps
Exam questions usually compress the concept into a short schedule, a compatibility check or a protocol claim. Watch these traps:
Serial is not the same as serializable. A schedule may interleave operations and still be equivalent to a serial order.
An S lock is not enough for a write. Writing requires an X lock.
2PL does not mean deadlock-free. Transactions can wait in a cycle while following 2PL.
Commit order does not reveal every earlier read. A transaction may already have consumed dirty data before the commits shown.
A correct final value is not a complete safety proof. An intermediate read may still have seen an invalid or uncommitted value.
Typical tasks are to locate the lost update in r1(A), r2(A), w1(A), w2(A); decide that S with S is compatible; flag a transaction acquiring a new lock after its first unlock as a 2PL violation; or compute 1050 for the unsafe schedule and 950 for its strict-2PL repair. Use the DBMS Transaction MCQs: 12 Solved (ACID, Locking) set to practise those decisions under time pressure.
Concurrency control short version and next step
For any schedule, ask four questions: which shared item is touched, which operations conflict, what would each serial order produce, and which protocol controls the conflict? Here, uncontrolled interleaving produced 1050; strict 2PL restored 950 by making T2 wait.
The CS Fundamentals for Exams & Placements category is the wider subject route. For a sequenced DBMS path with mixed practice, use GATE Guidance by Sanchit Sir. If you only need this concept, redraw both timelines and solve the linked transaction MCQs first.
Keep learning
Concurrency Control MCQs: 10 Solved DBMS Questions with Explanations
Test each option before reading the answer. These 10 DBMS questions build from conflict rules and anomalies to serializability, locks, and deadlock freedom.
Concurrency Control in DBMS: Anomalies, Serializability, Locking and 2PL with Worked Examples
Connect the full DBMS concurrency-control chain through one precedence-graph schedule, strict 2PL examples, timestamp rules and recovery checks.
Transactions and concurrency control in DBMS: ACID, schedules, serializability
Transactions in DBMS explained: ACID properties, schedules, conflict serializability with a worked precedence graph, two-phase locking, and the exam angle.
Introduction to Operating System: Core Concepts with a Worked CPU Schedule
Build a connected model of operating-system services, privilege, process states and kernel structures. Then trace an FCFS schedule with I/O and switching costs.





