Database Technology

Learn / Database Technology

DBT: 10 Concurrency Control

Practice questions on ACID properties, serializability, 2PL, deadlocks, isolation levels, OCC, and MVCC.

Learning path

0%

0 of 10 sections marked complete · about 67 minutes

Learning objectives

What you will be able to explain

  • In the context of ACID properties, which property ensures that a transaction is treated as an "all-or-nothing" unit of work, where either all operations are applied or none are?
  • Regarding the ACID properties:
  • What is the primary problem addressed by the "Isolation" property?
  • Analyze the schedule for conflict serializability.
  • Which statement correctly describes the relationship between Conflict Serializability and View Serializability?
  • Which of the following pairs of operations are in conflict?

Section 01

In the context of ACID properties, which property ensures that a transaction is treated as an "all-or-nothing" unit of work, where either all operations are applied or none are? to What is the primary problem addressed by the "Isolation" property?

01

In the context of ACID properties, which property ensures that a transaction is treated as an "all-or-nothing" unit of work, where either all operations are applied or none are?

Atomicity is the all-or-nothing guarantee: either the full transaction effects become durable or none of them do. Partial completion is not allowed.

02

Regarding the ACID properties:

A is True because consistency means constraints hold before and after committed transactions. B is False because durability is mainly recovery/logging responsibility, not lock management. C is True since isolation hides intermediate states. D is True because logging and recovery mechanisms implement atomic rollback/commit behavior.

03

What is the primary problem addressed by the "Isolation" property?

Isolation addresses concurrent-interference anomalies (dirty reads, lost updates, etc.) by controlling visibility and ordering among overlapping transactions.

Section 02

Analyze the schedule for conflict serializability. to Which of the following pairs of operations are in conflict?

01

Analyze the schedule for conflict serializability.

Path of Calculation: 1. Identify conflicting operations (different transactions, same item, at least one write). 2. r2(Y)w1(Y)r_2(Y) \rightarrow w_1(Y) creates an edge T2T1T_2 \rightarrow T_1. 3. w2(Y)r1(Y)w_2(Y) \rightarrow r_1(Y) creates an edge T2T1T_2 \rightarrow T_1. 4. w2(Y)w1(Y)w_2(Y) \rightarrow w_1(Y) creates an edge T2T1T_2 \rightarrow T_1. 5. The resulting precedence graph is T2T1T_2 \rightarrow T_1. 6. Since there are no cycles, the schedule is conflict-serializable. Correct Answer: Yes, it is conflict-serializable; equivalent to serial order (T2,T1)(T_2, T_1).

Guided checkpoint

Given schedule SS:

StepOperation
1r1(X)r_1(X)
2r2(Y)r_2(Y)
3w1(X)w_1(X)
4w2(Y)w_2(Y)
5r1(Y)r_1(Y)
6w1(Y)w_1(Y)

Determine whether SS is conflict-serializable and identify the equivalent serial order (if one exists).

02

Which statement correctly describes the relationship between Conflict Serializability and View Serializability?

Conflict-serializable schedules are a subset of view-serializable schedules, so every conflict-serializable schedule is also view-serializable.

03

Which of the following pairs of operations are in conflict?

Two operations conflict when they are from different transactions, access the same item, and at least one is a write. That matches B (read-write on X) and D (write-write on X).

Section 03

Complete the Lock Compatibility Matrix (Yes = Compatible, No = Conflict): to Evaluate the sequence under Two-Phase Locking (2PL).

01

Complete the Lock Compatibility Matrix (Yes = Compatible, No = Conflict):

Shared locks are compatible with shared locks, so S/S is Yes. Any request involving an exclusive lock against an existing S or X lock conflicts, so S/X and X/X are No.

02

What is the defining rule of the Two-Phase Locking (2PL) protocol?

2PL has a growing phase (acquire locks) and shrinking phase (release locks). Once any lock is released, no new locks may be acquired.

03

Evaluate the sequence under Two-Phase Locking (2PL).

Path of Calculation: 1. The "Growing Phase" is LockS(A),LockX(B)Lock_S(A), Lock_X(B). 2. The "Shrinking Phase" starts at Unlock(A)Unlock(A). 3. According to 2PL, once you enter the shrinking phase (by unlocking), you cannot acquire new locks. 4. Therefore, LockS(C)Lock_S(C) after Unlock(A)Unlock(A) is a violation. Correct Answer: The first sequence is valid 2PL. Adding LockS(C)Lock_S(C) after Unlock(A)Unlock(A) makes it NOT 2PL.

Guided checkpoint

A transaction TT follows the Two-Phase Locking protocol and performs this sequence:

LockS(A),Read(A),LockX(B),Write(B),Unlock(A),Unlock(B)Lock_S(A), Read(A), Lock_X(B), Write(B), Unlock(A), Unlock(B)

Is this valid according to 2PL? If TT then tried to LockS(C)Lock_S(C) after Unlock(A)Unlock(A), would it still be 2PL?

Section 04

What is the primary difference between Basic 2PL and Strict 2PL? to In hierarchical locking (Multiple Granularity Locking), what does an "Intention Exclusive" (IX) lock at the Table level signify?

01

What is the primary difference between Basic 2PL and Strict 2PL?

Strict 2PL keeps X locks until commit/abort, preventing other transactions from seeing uncommitted writes and thereby avoiding cascading aborts.

02

Regarding 2PL variations:

A is False because 2PL can still deadlock. B is True: strictness prevents reading uncommitted written data. C is True: rigorous 2PL holds both S and X locks to commit. D is True: 2PL guarantees conflict-serializability.

03

In hierarchical locking (Multiple Granularity Locking), what does an "Intention Exclusive" (IX) lock at the Table level signify?

An IX lock at table level signals intent to acquire exclusive locks on descendants (pages/rows). It is an intention marker, not full-table exclusive ownership.

Section 05

Transaction T1T_1 holds an IX lock on Table RR. Transaction T2T_2 requests an S lock on Table RR. Based on the compatibility matrix for intention locks, should T2T_2 be granted the lock? to Which deadlock prevention strategy aborts the younger transaction if it requests a lock held by an older transaction?

01

Transaction T1T_1 holds an IX lock on Table RR. Transaction T2T_2 requests an S lock on Table RR. Based on the compatibility matrix for intention locks, should T2T_2 be granted the lock?

Path of Calculation: 1. Check IX compatibility with S. 2. IX means someone is writing a lower node. S means someone wants to read the whole node. 3. These are incompatible because the whole-node reader (S) cannot be sure the lower-level writer (X) isn't changing data they are reading. Correct Answer: No.

02

Which of the following lock modes are compatible with a "Shared Intention Exclusive" (SIX) lock?

SIX combines shared access at the node with intention to take exclusive locks below. In standard compatibility, only IS can coexist safely with SIX at the same node.

03

Which deadlock prevention strategy aborts the younger transaction if it requests a lock held by an older transaction?

In Wait-Die, older transactions are allowed to wait, while younger requesters die (abort) when they need a lock held by an older transaction.

Section 06

In a "Wait-For Graph", Transaction T1T_1 is waiting for a lock held by T2T_2, T2T_2 is waiting for T3T_3, and T3T_3 is waiting for T1T_1. What does this state represent, and what action must the Lock Manager take? to Match the read phenomenon to its definition:

01

In a "Wait-For Graph", Transaction T1T_1 is waiting for a lock held by T2T_2, T2T_2 is waiting for T3T_3, and T3T_3 is waiting for T1T_1. What does this state represent, and what action must the Lock Manager take?

Path of Calculation: 1. Nodes: T1,T2,T3T_1, T_2, T_3. Edges: T1T2,T2T3,T3T1T_1 \rightarrow T_2, T_2 \rightarrow T_3, T_3 \rightarrow T_1. 2. This forms a cycle: T1T2T3T1T_1 \rightarrow T_2 \rightarrow T_3 \rightarrow T_1. 3. A cycle in the Wait-For graph indicates a Deadlock. 4. The Lock Manager must select a "victim" transaction to abort. Correct Answer: This is a Deadlock; the Lock Manager must abort one of the transactions.

02

What is the main drawback of the "Timeout-based" deadlock detection?

Timeout detection is simple but imprecise: long waits can be mistaken for deadlocks, causing unnecessary aborts even when no cycle exists.

03

Match the read phenomenon to its definition:

Dirty Read means reading uncommitted data. Non-repeatable Read means the same row value changes between reads in one transaction. Phantom Read means a repeated predicate query returns a changed row set due to concurrent inserts/deletes.

Section 07

Which SQL isolation level provides the highest level of protection by preventing all three phenomena (Dirty Read, Non-repeatable Read, Phantom)? to What are the three phases of Optimistic Concurrency Control?

01

Which SQL isolation level provides the highest level of protection by preventing all three phenomena (Dirty Read, Non-repeatable Read, Phantom)?

Serializable is the strongest SQL isolation level and prevents dirty reads, non-repeatable reads, and phantoms by enforcing serial-equivalent behavior.

02

Regarding SQL Isolation Levels:

A is True since Read Committed is widely used as default. B is False because row locks alone do not fully prevent phantoms. C is True because Read Uncommitted allows reading data that may roll back. D is False: stronger isolation usually reduces concurrency.

03

What are the three phases of Optimistic Concurrency Control?

OCC runs transactions in Read, then Validation, then Write phase. It avoids lock-heavy coordination during read and checks conflicts before commit.

Section 08

In OCC, when is the "Validation Phase" performed? to In Snapshot Isolation, which version of a data item does a transaction TT read?

01

In OCC, when is the "Validation Phase" performed?

Validation occurs at commit time boundary: before making writes visible, OCC verifies that serializability/conflict conditions still hold.

02

What is the primary assumption behind Optimistic Concurrency Control?

OCC is based on the optimistic assumption that conflicts are infrequent, so doing work without locks and occasionally restarting is cheaper overall.

03

In Snapshot Isolation, which version of a data item does a transaction TT read?

Snapshot Isolation gives each transaction a stable snapshot as of its start timestamp, so reads see the latest committed version at transaction start, not at read time.

Section 09

Under Snapshot Isolation, which version of XX does T1T_1 see? to Regarding Multi-version Concurrency Control (MVCC):

01

Under Snapshot Isolation, which version of XX does T1T_1 see?

Path of Calculation: 1. Under SI, a transaction sees the state of the DB as of its Start Timestamp (STST). 2. T1T_1's STST is 10. 3. Any updates committed after time 10 are invisible to T1T_1. 4. T2T_2's update committed at time 20, which is >10> 10. Correct Answer: T1T_1 sees the version of XX that existed at time 10 (the version before T2T_2's update).

Guided checkpoint

Given the following timeline:

TimeEvent
10T1T_1 starts (ST=10ST=10)
15T2T_2 starts (ST=15ST=15)
20T2T_2 updates XX and commits (CT=20CT=20)
25T1T_1 reads XX

Determine which version of XX is visible to T1T_1.

02

What is the "First-Committer-Wins" rule in Snapshot Isolation used for?

First-Committer-Wins resolves concurrent write-write conflicts by allowing only the earliest committer to succeed, preventing lost updates under SI.

03

Regarding Multi-version Concurrency Control (MVCC):

MVCC lets readers use stable versions without blocking writers, and writers can create new versions without blocking readers in common cases. Old versions must be garbage-collected. MVCC supports multiple isolation levels, not only Read Uncommitted.

Section 10

What is the "Write Skew" anomaly? to A system uses "Wound-Wait". ToldT_{old} (Start Time 100) requests a lock held by TyoungT_{young} (Start Time 200). What happens? Conversely, what happens if TyoungT_{young} requests a lock held by ToldT_{old}?

01

What is the "Write Skew" anomaly?

Write skew occurs when concurrent transactions read overlapping predicates but update different rows, jointly violating a cross-row constraint. Snapshot Isolation is known to permit this anomaly.

02

Which component of the DBMS architecture is responsible for managing the lifecycle of locks?

The lock manager grants, queues, upgrades, and releases locks and handles deadlock-related decisions, making it the component that controls lock lifecycle.

03

A system uses "Wound-Wait". ToldT_{old} (Start Time 100) requests a lock held by TyoungT_{young} (Start Time 200). What happens? Conversely, what happens if TyoungT_{young} requests a lock held by ToldT_{old}?

Path of Calculation: 1. Wound-Wait Rule: If TreqT_{req} is older than TheldT_{held}, TreqT_{req} "wounds" (aborts) TheldT_{held}. 2. Wound-Wait Rule: If TreqT_{req} is younger than TheldT_{held}, TreqT_{req} waits. 3. Scenario 1: 100<200Told100 < 200 \rightarrow T_{old} wounds TyoungT_{young}. 4. Scenario 2: 200>100Tyoung200 > 100 \rightarrow T_{young} waits. Correct Answer: In the first case, TyoungT_{young} is aborted. In the second case, TyoungT_{young} waits.

Knowledge check

Turn understanding into recall.

The quiz now follows the same concepts in scored form. You can return to this lesson from the quiz whenever a gap appears.