Skip to main content

Databases (DBMS)

Transactions & Concurrency Control

Transactions bring everything together: decide whether a schedule is serializable and recoverable, choose the locking protocol that guarantees it, and know how the log restores the database after a crash.

~6 hrs ~1–1.5 marks · Must-score 10 samples · 8 practice · 9 cards

GATE CSE transactions and concurrency control — ACID, schedules, conflict and view serializability, precedence graphs, 2PL variants, deadlock handling, timestamp ordering with the Thomas write rule, recoverability classes and log-based UNDO/REDO recovery, with sample questions, flashcards and drills.

Learning outcomes

  • State ACID and the anomalies that weaker isolation allows
  • Draw precedence graphs and decide conflict and view serializability
  • Compare basic, strict, rigorous and conservative 2PL and timestamp ordering with the Thomas write rule
  • Classify schedules as recoverable, cascadeless or strict and apply UNDO/REDO recovery

ACID, schedules and isolation anomalies

  • A TRANSACTION is a logical unit of work made of reads and writes (r(X), w(X)) ended by COMMIT or ABORT. ACID: ATOMICITY (all or nothing; ensured by the recovery manager using logs), CONSISTENCY (a correct transaction moves the database from one consistent state to another), ISOLATION (concurrent execution behaves as if serial; ensured by concurrency control), DURABILITY (committed changes survive failures; ensured by logging and recovery).
  • A SCHEDULE is an interleaving of the operations of several transactions that preserves the order of operations inside each transaction. A SERIAL schedule runs transactions one after the other: n transactions have n! serial schedules. The number of interleavings of transactions with m1, m2, ... operations is (m1 + m2 + ...)! / (m1! m2! ...).
  • TRANSACTION STATES: active, partially committed, committed, failed, aborted (terminated).
  • ANOMALIES: DIRTY READ (reading uncommitted data), NON-REPEATABLE READ (a row read twice gives different values), PHANTOM (new rows appear in a repeated range query), LOST UPDATE (two updates overwrite each other).
  • SQL ISOLATION LEVELS: READ UNCOMMITTED (allows dirty reads), READ COMMITTED (no dirty read), REPEATABLE READ (no dirty or non-repeatable read; phantoms possible), SERIALIZABLE (no anomalies).
  • CONFLICTING operations: two operations of DIFFERENT transactions on the SAME item where at least one is a write: read-write, write-read, write-write. Read-read never conflicts.
  • LOST UPDATE example: r1(A) r2(A) w1(A) w2(A): both read the same old value, T1’s write is overwritten by T2’s. DIRTY READ example: w1(A) r2(A) a1: T2 used a value that never became permanent. Both are prevented by serializable execution.
  • WHICH COMPONENT ENSURES WHAT: Atomicity and Durability -> recovery manager (undo/redo using the log); Isolation -> concurrency-control manager (locks, timestamps); Consistency -> the application programmer plus integrity constraints checked by the DBMS.
  • Why serial schedules are correct: each transaction alone preserves consistency, so running them one after another does too. A concurrent schedule is accepted when it is EQUIVALENT to a serial one (conflict or view equivalent).

Formulas to remember

  • n transactions: n! serial schedules
  • Total interleavings = (m1 + m2 + ... + mk)! / (m1! m2! ... mk!)
Isolation levelDirty readNon-repeatable readPhantom
Read uncommittedpossiblepossiblepossible
Read committednopossiblepossible
Repeatable readnonopossible
Serializablenonono

Worked example

Problem. T1 has 3 operations and T2 has 2 operations. How many different schedules (interleavings) are possible?

Solution. Choose which 2 of the 5 positions are taken by T2 (the order inside each transaction is fixed): C(5, 2) = 10 interleavings, of which 2 are serial.

Four cards for atomicity, consistency, isolation and durability with the DBMS component that ensures each, plus the isolation anomalies and levels table.
ACID for a funds transfer: the recovery manager gives atomicity and durability, concurrency control gives isolation, and consistency comes from correct programs plus integrity constraints.

Serializability and recoverability

  • CONFLICT SERIALIZABLE (CSR): the schedule is conflict equivalent to some serial schedule (the order of every pair of conflicting operations is the same). TEST: build the PRECEDENCE GRAPH with a node per transaction and an edge Ti -> Tj whenever an operation of Ti conflicts with a LATER operation of Tj. The schedule is CSR iff the graph has NO CYCLE; a topological order gives an equivalent serial schedule.
  • VIEW SERIALIZABLE (VSR): view equivalent to a serial schedule: (1) each transaction reads the same initial value, (2) each read sees the value written by the same transaction (reads-from), (3) the final write on every item is by the same transaction. Every CSR schedule is VSR but not conversely; a VSR schedule that is not CSR must contain BLIND WRITES (writes without a prior read). Testing VSR is NP-complete.
  • RECOVERABLE: if Tj reads an item written by Ti, then Ti must COMMIT BEFORE Tj commits (otherwise Tj would have to be undone but is already committed). CASCADELESS (ACA): transactions read only COMMITTED values, so an abort never triggers cascading rollbacks. STRICT: no transaction reads OR overwrites an item written by an uncommitted transaction.
  • Hierarchy: STRICT is a subset of CASCADELESS, which is a subset of RECOVERABLE. Serializability and recoverability are independent properties: a schedule can be serializable but not recoverable and vice versa.
  • IRRECOVERABLE example: w1(X) r2(X) c2 c1. RECOVERABLE but not cascadeless: w1(X) r2(X) c1 c2 (T2 read uncommitted data; if T1 aborted, T2 must roll back). Cascadeless but not strict: w1(X) w2(X) c1 c2.
  • Equivalent serial order from a topological sort of the precedence graph; if the graph has several topological orders, all are equivalent serial schedules.
  • The number of schedules that are conflict-equivalent to a given serial order equals the number of ways to interleave non-conflicting operations; GATE usually only asks about a cycle test or the equivalent serial order.
Operation of Ti (earlier)Operation of Tj (later)Conflict?Edge
r(X)r(X)nonone
r(X)w(X)yes (RW)Ti -> Tj
w(X)r(X)yes (WR)Ti -> Tj
w(X)w(X)yes (WW)Ti -> Tj
any on Xany on Y (Y different from X)nonone

Worked example

Problem. Is S: r1(A) r2(B) w1(B) w2(A) conflict serializable?

Solution. Conflicts: r1(A) before w2(A) gives T1 -> T2; r2(B) before w1(B) gives T2 -> T1. The precedence graph has the cycle T1 -> T2 -> T1, so S is NOT conflict serializable. By contrast S: r1(A) w1(A) r2(A) w2(A) r1(B) w1(B) has only the edge T1 -> T2 (the B operations belong to T1 alone): it is serializable as T1 then T2.

Two schedules with their precedence graphs: an acyclic graph T1 to T2 to T3 that is conflict serializable and a cycle T1 to T2 to T3 to T1 that is not.
Precedence graph test: draw an edge Ti -> Tj for each earlier conflicting operation of Ti and later one of Tj. No cycle means conflict serializable; a topological order is an equivalent serial schedule.

Worked serializability problems: precedence graphs and view serializability

  • PROCEDURE: (1) list each item and the operations on it in schedule order; (2) for each item, add edges from every earlier operation to every later conflicting operation of a different transaction; (3) merge edges; (4) look for a cycle; (5) if acyclic, write a topological order.
  • Edges can be derived item by item: all writes and reads of the same item need only pairwise checks within that item, so do not compare operations on different items.
  • The number of equivalent serial schedules of an acyclic precedence graph equals the number of topological orders. A chain has exactly one; a graph with no edges has n!.
  • VIEW SERIALIZABILITY: check the three view conditions against each candidate serial order: same initial reads, same reads-from pairs, same final writes. A schedule that is not conflict serializable but is view serializable always contains a BLIND WRITE.
  • A schedule with only reads is trivially conflict serializable (no conflicts). A schedule with transactions on disjoint items is serializable in every order.
  • For m transactions the number of possible serial orders is m!; GATE sometimes asks "how many serial schedules are conflict equivalent to S", which is the number of topological orders of S’s precedence graph.

Worked example

Problem. Check conflict serializability of S1: r2(A) r1(B) w2(A) r3(A) w1(B) w3(A) r2(B) w2(B), and of S2: w1(A) r2(A) w2(B) r3(B) w3(C) r1(C). Then decide whether S3: r1(A) w2(A) w1(A) w3(A) is view serializable.

Solution. S1, item A: r2(A), w2(A), r3(A), w3(A): every conflict goes from T2 to T3 (r2-w3, w2-r3, w2-w3), edge T2 -> T3. Item B: r1(B), w1(B), r2(B), w2(B): r1-w2, w1-r2, w1-w2 give T1 -> T2. Edges T1 -> T2 and T2 -> T3, no cycle, so S1 is conflict serializable with the unique serial order T1, T2, T3. S2: w1(A) before r2(A) gives T1 -> T2; w2(B) before r3(B) gives T2 -> T3; w3(C) before r1(C) gives T3 -> T1: a cycle, so S2 is NOT conflict serializable. S3: r1(A) before w2(A) gives T1 -> T2; w2(A) before w1(A) gives T2 -> T1: cycle, so not conflict serializable. View check against serial order T1, T2, T3: T1 reads the initial value of A in both S3 and the serial order; no other transaction reads, so reads-from pairs agree; the final write on A is by T3 in both. So S3 is view serializable but not conflict serializable (T2 and T3 write blindly).

Recoverability classification: worked cases

  • Work on one item at a time: for every read r_j(X) find the last write w_i(X) before it by a different transaction (the reads-from relation i -> j). Then compare commit/abort positions.
  • RECOVERABLE: for every reads-from pair (Ti writes, Tj reads), c_i is before c_j. CASCADELESS (ACA): for every reads-from pair, c_i is before the READ r_j. STRICT: c_i or a_i is before any read OR write by another transaction of the item that Ti wrote.
  • Because strict is a subset of cascadeless, which is a subset of recoverable, test in the order irrecoverable, recoverable, cascadeless, strict and name the strongest class that holds.
  • Recoverability says nothing about serializability: S = r1(A) w1(A) r2(A) w2(A) c2 c1 is conflict serializable (T1 -> T2) yet irrecoverable.
ScheduleClassReason
w1(X) r2(X) c2 c1irrecoverableT2 read from T1 but committed first
w1(X) r2(X) c1 c2recoverable, not cascadelessT2 read before T1 committed
w1(X) c1 r2(X) c2strictT2 touches X only after T1 committed
w1(X) w2(X) c1 c2cascadeless, not strictno reads, but T2 overwrites uncommitted data
r1(X) w2(X) c1 c2strictT1 only READ X, nothing uncommitted is written
w1(X) r2(X) a1 a2recoverable, not cascadelessT2 read dirty data and must also abort

Worked example

Problem. Classify S: w1(A) r2(A) w2(B) c2 c1 and S’: w1(A) r2(A) c1 c2 and S’’: w1(A) c1 w2(A) r3(A) c2 c3.

Solution. S: T2 reads A written by T1 (reads-from T1 -> T2), but c2 appears before c1, so S is irrecoverable. S’: same reads-from pair with c1 before c2, so recoverable; T2’s read happens before c1, so it is not cascadeless. S’’: T2 writes A only after c1, so T1 causes no problem. T3 reads A written by T2 (reads-from T2 -> T3), but r3(A) occurs BEFORE c2, so T3 reads uncommitted data and the schedule is not cascadeless; c2 is before c3, so it is recoverable. S’’ is recoverable but not cascadeless.

Locking protocols, timestamps, deadlocks and recovery

  • LOCKS: shared (S) for reading, exclusive (X) for writing; S is compatible with S only. TWO-PHASE LOCKING (2PL): each transaction has a GROWING phase (acquire locks, no release) followed by a SHRINKING phase (release only, no new locks). The LOCK POINT is the end of the growing phase. 2PL guarantees CONFLICT SERIALIZABILITY (order = lock-point order) but NOT freedom from deadlock and NOT recoverability/cascadelessness.
  • VARIANTS: STRICT 2PL holds all EXCLUSIVE locks until commit/abort, so schedules are STRICT (hence cascadeless and recoverable). RIGOROUS 2PL holds ALL locks (shared and exclusive) until commit; serialization order = commit order. CONSERVATIVE (static) 2PL acquires all locks before starting, so it is DEADLOCK-FREE but needs advance knowledge of data items.
  • MULTIPLE GRANULARITY: intention locks IS, IX, SIX allow locking at table/page/row level; to lock a node in S or X, intention locks are first taken on its ancestors from the root downwards.
  • DEADLOCK: detection by a WAIT-FOR GRAPH (a cycle means deadlock; choose a victim to abort). Prevention by TIMESTAMPS: WAIT-DIE (non-preemptive): an older requester waits for a younger holder, a younger requester dies (aborts). WOUND-WAIT (preemptive): an older requester wounds (aborts) the younger holder, a younger requester waits. Both avoid starvation if aborted transactions keep their original timestamp.
  • TIMESTAMP ORDERING (TO): each item Q keeps R-TS(Q) and W-TS(Q). READ by T: if W-TS(Q) > TS(T) rollback T; else execute and set R-TS(Q) = max(R-TS(Q), TS(T)). WRITE by T: if R-TS(Q) > TS(T) rollback T; else if W-TS(Q) > TS(T) rollback T (basic TO) or IGNORE the write (THOMAS WRITE RULE, since it is obsolete); else execute and set W-TS(Q) = TS(T). Basic TO ensures conflict serializability and is deadlock-free but not recoverable by itself.
  • The Thomas write rule can allow VIEW-serializable schedules that are not conflict-serializable.
  • LOG-BASED RECOVERY uses WRITE-AHEAD LOGGING (WAL): log records <T start>, <T, X, old, new>, <T commit>, <T abort> reach stable storage before the data change. DEFERRED modification: writes applied only after commit, recovery needs only REDO. IMMEDIATE modification: writes may reach disk before commit, recovery needs both UNDO and REDO.
  • RECOVERY after a crash: scan the log from the last CHECKPOINT; transactions with both <start> and <commit> are REDONE; transactions with <start> but no commit/abort are UNDONE (old values restored, in reverse order). Checkpoints limit how far back the log must be examined. ARIES uses a steal/no-force policy with analysis, redo and undo phases.
ProtocolSerializable?Deadlock-free?Cascadeless?
Basic 2PLyes (conflict)nonot guaranteed
Strict 2PLyes (conflict)noyes (strict schedules)
Rigorous 2PLyes (commit order)noyes
Conservative 2PLyesyesnot guaranteed
Timestamp orderingyes (conflict)yes (no waiting)not guaranteed

Worked example

Problem. Log: <T1 start> <T1, A, 10, 20> <T1 commit> <T2 start> <T2, B, 5, 8> then a crash occurs. What does the recovery manager do (immediate modification)?

Solution. T1 has a commit record, so REDO T1: set A = 20. T2 started but has no commit, so UNDO T2: restore B = 5 (the old value). Recovery therefore needs both redo and undo.

A chart of locks held over time with the growing phase, lock point and shrinking phase, the shared and exclusive lock compatibility matrix, and a table comparing basic, strict, rigorous and conservative two-phase locking.
Two-phase locking: acquire locks only until the lock point, then release only. Serialization order follows lock points; strict and rigorous 2PL also give cascadeless schedules, conservative 2PL avoids deadlock.

Worked problems: 2PL, deadlock prevention and timestamp ordering

  • TEST WHETHER A TRANSACTION OBEYS 2PL: scan its lock/unlock sequence; once an unlock appears, no lock may follow. A schedule is 2PL-allowed if every transaction in it satisfies this and no lock conflict is violated (an X lock never overlaps another lock on the same item).
  • DEADLOCK DETECTION: build the WAIT-FOR graph with an edge Ti -> Tj when Ti waits for a lock held by Tj. A cycle means deadlock; choose a victim (usually the youngest or the one with the least work) and roll it back.
  • WAIT-DIE (non-preemptive): older requester waits, younger requester dies. WOUND-WAIT (preemptive): older requester wounds (aborts) the younger holder, younger requester waits. Smaller timestamp = older transaction.
  • TIMESTAMP ORDERING READ: if TS(T) < W-TS(Q) rollback; otherwise read and set R-TS(Q) = max(R-TS(Q), TS(T)). WRITE: if TS(T) < R-TS(Q) rollback; if TS(T) < W-TS(Q) rollback (basic) or ignore (Thomas); otherwise write and set W-TS(Q) = TS(T).
  • A rolled-back transaction restarts with a NEW timestamp under basic TO (a risk of starvation), but keeps its ORIGINAL timestamp under wait-die and wound-wait (which guarantees that it eventually becomes the oldest).
Requester vs holder (TS: T1 = 5 older, T2 = 10 younger)Wait-dieWound-wait
T1 (older) requests lock held by T2 (younger)T1 waitsT1 wounds T2 (T2 aborts)
T2 (younger) requests lock held by T1 (older)T2 dies (aborts)T2 waits

Worked example

Problem. TS(T1) = 5 and TS(T2) = 10; item X starts with R-TS = W-TS = 0. Consider (a) r2(X) then w1(X) and (b) w2(X) then w1(X). Which operations succeed under basic timestamp ordering and under the Thomas write rule? Also give the wait-for graph for: T1 holds X(A), T2 holds X(B), T1 requests B, T2 requests A.

Solution. (a) r2(X): W-TS = 0 <= 10, so it executes and R-TS(X) = 10. w1(X): TS(T1) = 5 < R-TS(X) = 10, so T1 is rolled back, under both rules (the read by the younger T2 must not be invalidated). (b) w2(X): R-TS = 0 <= 10 and W-TS = 0 <= 10, so it executes and W-TS(X) = 10. w1(X): TS(T1) = 5 is not smaller than R-TS (0), but 5 < W-TS = 10: basic TO rolls T1 back; the Thomas write rule ignores the write because T2’s later value would overwrite it anyway, and T1 continues. Wait-for graph: T1 requested B held by T2 gives T1 -> T2; T2 requested A held by T1 gives T2 -> T1. The cycle T1 -> T2 -> T1 is a deadlock; one transaction must be aborted.

Exam tips

  • Precedence graph: edge Ti -> Tj for a conflict (RW, WR, WW) where Ti operates first; a cycle means NOT conflict serializable.
  • Every conflict-serializable schedule is view serializable; a view-serializable schedule that is not conflict-serializable has blind writes.
  • Recoverable: a reader commits after the transaction it read from. Cascadeless: read only committed data. Strict: no read or write of uncommitted data.
  • 2PL guarantees serializability but not deadlock freedom; strict 2PL also gives cascadeless and strict schedules; conservative 2PL avoids deadlock.
  • Timestamp ordering: a read is rejected if W-TS > TS(T); a write is rejected if R-TS > TS(T); an obsolete write (W-TS > TS(T)) is skipped under the Thomas rule.
Exam pattern · 10 questions

GATE sample questions & answers

10 GATE-style MCQs for Transactions & Concurrency Control with full explanations. Attempt each question before revealing the answer.

Q1 Classic GATE precedence-graph question

Consider the schedule S: r1(X) r2(X) w1(X) w2(X). Which statement is true?

  • A) S is conflict serializable as T1 then T2
  • B) S is conflict serializable as T2 then T1
  • C) S is not conflict serializable
  • D) S is serial
Show answer & explanation

Answer: C

r2(X) before w1(X) gives T2 -> T1; r1(X) before w2(X) gives T1 -> T2. The cycle means S is not conflict serializable.

Q2

The number of serial schedules of 3 transactions is:

  • A) 3
  • B) 6
  • C) 9
  • D) 27
Show answer & explanation

Answer: B

There are 3! = 6 orderings of the three transactions.

Q3

The schedule S: w1(X) r2(X) c2 c1 is:

  • A) recoverable and cascadeless
  • B) recoverable but not cascadeless
  • C) not recoverable
  • D) strict
Show answer & explanation

Answer: C

T2 reads X written by T1 and commits before T1 commits, so the schedule is not recoverable (if T1 aborts, committed T2 cannot be undone).

Q4

The schedule S: w1(X) r2(X) c1 c2 is:

  • A) not recoverable
  • B) recoverable but not cascadeless
  • C) cascadeless
  • D) strict
Show answer & explanation

Answer: B

T1 commits before T2, so S is recoverable; but T2 read uncommitted data of T1, so an abort of T1 would cascade: not cascadeless.

Q5

Strict two-phase locking guarantees:

  • A) conflict serializability and freedom from deadlock
  • B) conflict serializability and strict (cascadeless) schedules, but not freedom from deadlock
  • C) only recoverability
  • D) view serializability only
Show answer & explanation

Answer: B

Holding exclusive locks until commit gives strict schedules; 2PL ensures conflict serializability; deadlocks are still possible.

Q6

In timestamp ordering, TS(T1) = 5 and W-TS(X) = 8. T1 issues read(X). What happens?

  • A) the read is executed and R-TS(X) = 5
  • B) T1 is rolled back
  • C) the read is ignored
  • D) T1 waits for the lock
Show answer & explanation

Answer: B

A younger transaction (TS 8) has already written X, so the read would see a value from the future: since W-TS(X) > TS(T1), T1 is rolled back.

Q7

TS(T) = 5, R-TS(X) = 3, W-TS(X) = 8. T issues write(X). Under the Thomas write rule:

  • A) T is rolled back
  • B) the write is executed and W-TS(X) = 5
  • C) the write is ignored and T continues
  • D) T waits
Show answer & explanation

Answer: C

R-TS(X) = 3 is not greater than 5, so there is no read conflict; W-TS(X) = 8 > 5 means the write is obsolete and is skipped (basic TO would roll T back).

Q8

S: r1(X) w2(X) w1(X) w3(X). Which statement is correct?

  • A) S is conflict serializable
  • B) S is view serializable but not conflict serializable
  • C) S is not view serializable
  • D) S is a serial schedule
Show answer & explanation

Answer: B

r1(X) before w2(X) gives T1 -> T2 and w2(X) before w1(X) gives T2 -> T1: a cycle, so not conflict serializable. S is view equivalent to T1, T2, T3: T1 reads the initial X and T3 makes the final write, and the blind writes in between do not matter.

Q9

A crash occurs after the log <T1 start>, <T1, A, 10, 20>, <T1 commit>, <T2 start>, <T2, B, 5, 8>. Recovery performs:

  • A) redo T1 and redo T2
  • B) redo T1 and undo T2
  • C) undo T1 and undo T2
  • D) undo T1 and redo T2
Show answer & explanation

Answer: B

T1 committed, so its updates are redone; T2 did not commit, so its update is undone using the old value.

Q10

T1 has 3 operations and T2 has 2 operations. The number of possible schedules (interleavings) is:

  • A) 5
  • B) 6
  • C) 10
  • D) 120
Show answer & explanation

Answer: C

C(5, 2) = 10 ways to interleave the two sequences while keeping each transaction’s own order.

Topic drill · 8 questions

8 practice questions — Transactions & Concurrency Control

Extra page-specific practice beyond the GATE samples. Attempt all 8, then reveal answers to check your reasoning.

P1

S: r1(A) w1(A) r2(A) w2(A) r1(B) w1(B). The schedule is:

  • A) conflict serializable (T1 then T2)
  • B) conflict serializable (T2 then T1)
  • C) not conflict serializable
  • D) not recoverable
Show answer & explanation

Answer: A) conflict serializable (T1 then T2)

The only conflicts are on A with T1 first, giving a single edge T1 -> T2. The operations on B belong to T1 alone.

P2

S: r1(A) r2(B) w1(B) w2(A). The precedence graph has:

  • A) no edges
  • B) edge T1 -> T2 only
  • C) edges T1 -> T2 and T2 -> T1
  • D) edge T2 -> T1 only
Show answer & explanation

Answer: C) edges T1 -> T2 and T2 -> T1

r1(A) before w2(A) gives T1 -> T2; r2(B) before w1(B) gives T2 -> T1. The cycle shows S is not conflict serializable.

P3

Which of the following is TRUE about two-phase locking?

  • A) it prevents deadlock
  • B) it guarantees conflict serializability
  • C) it guarantees cascadeless schedules
  • D) it allows a transaction to acquire locks after releasing one
Show answer & explanation

Answer: B) it guarantees conflict serializability

Basic 2PL guarantees serializability only; deadlocks and cascading rollbacks can still occur, and no lock may be acquired after the first release.

P4

Which locking protocol is deadlock-free?

  • A) basic 2PL
  • B) strict 2PL
  • C) rigorous 2PL
  • D) conservative 2PL
Show answer & explanation

Answer: D) conservative 2PL

Conservative 2PL acquires all required locks before the transaction begins, so no hold-and-wait is possible.

P5

S: w1(X) w2(X) c1 c2 belongs to which class?

  • A) not recoverable
  • B) recoverable and cascadeless but not strict
  • C) strict
  • D) recoverable but not cascadeless
Show answer & explanation

Answer: B) recoverable and cascadeless but not strict

There are no reads, so no transaction reads uncommitted data (cascadeless and recoverable). T2 overwrites T1’s uncommitted write, so it is not strict.

P6

Under wait-die, T1 (timestamp 5) requests a lock held by T2 (timestamp 10). What happens?

  • A) T1 waits
  • B) T1 is aborted
  • C) T2 is aborted
  • D) both are aborted
Show answer & explanation

Answer: A) T1 waits

In wait-die an older requester waits for a younger holder; a younger requester would be aborted (die).

P7

Under wound-wait, T1 (timestamp 5) requests a lock held by T2 (timestamp 10). What happens?

  • A) T1 waits
  • B) T1 is aborted
  • C) T2 is aborted (wounded)
  • D) nothing, the lock is shared
Show answer & explanation

Answer: C) T2 is aborted (wounded)

In wound-wait the older requester wounds (preempts) the younger holder; a younger requester waits.

P8

With deferred database modification, after a crash the recovery manager needs to:

  • A) only undo uncommitted transactions
  • B) only redo committed transactions
  • C) both undo and redo every transaction
  • D) do nothing
Show answer & explanation

Answer: B) only redo committed transactions

Writes reach the database only after commit, so uncommitted transactions left no changes to undo.

Topic FAQs

How do I test conflict serializability?

Build the precedence graph with an edge Ti -> Tj for each pair of conflicting operations where Ti comes first. The schedule is conflict serializable if and only if the graph has no cycle.

Does two-phase locking prevent deadlock?

No. 2PL guarantees conflict serializability but transactions can wait for each other in a cycle. Only conservative 2PL (all locks acquired before starting) or timestamp-based prevention schemes avoid deadlock.

What is the difference between recoverable, cascadeless and strict schedules?

Recoverable: a transaction commits only after those it read from commit. Cascadeless: a transaction reads only committed values. Strict: no transaction reads or overwrites data written by an uncommitted transaction. Strict is a subset of cascadeless, which is a subset of recoverable.

What does the Thomas write rule change?

When a write arrives that is older than the item’s write timestamp (but newer than its read timestamp), the write is simply ignored as obsolete instead of aborting the transaction. This permits some view-serializable schedules.

Quick revision · 9 cards

9 flashcards — Transactions & Concurrency Control

Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.

Q1 What does ACID stand for and who enforces it?
Q2 Conflict serializability test?
Q3 CSR vs VSR?
Q4 Recoverable, cascadeless, strict order?
Q5 Basic vs strict vs rigorous vs conservative 2PL?
Q6 Wait-die vs wound-wait?
Q7 Timestamp write rule?
Q8 Deferred vs immediate modification?
Q9 Recovery rule with a checkpoint?