Questions: Deadlocks in Databases

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Transaction T1 holds a lock on row A and is waiting for a lock on row B. Transaction T2 holds a lock on row B and is waiting for a lock on row A. What best describes this situation?

AA race condition — the transaction that commits first wins, and the loser must retry
BA deadlock — a cycle exists in the wait-for graph, and neither transaction can proceed without external intervention
CA livelock — both transactions keep releasing and re-acquiring locks without making progress
DA serialization failure — the transactions have conflicting schedules that cannot be serialized
Question 2 Multiple Choice

A database detects a deadlock and aborts transaction T2, rolling back its changes. What is the correct next step for the application?

AReport a fatal database error — deadlocks indicate data corruption requiring manual recovery
BRetry T2 from scratch — deadlock aborts are normal events that application code should handle with retry logic
CWait for T1 to commit, then re-acquire T2's original locks in reverse order to prevent future deadlocks
DEscalate to table-level locks to prevent the row-level contention that caused the deadlock
Question 3 True / False

Imposing a global lock-ordering rule (e.g., typically lock rows in ascending primary key order) prevents deadlocks by eliminating the 'hold and wait' Coffman condition.

TTrue
FFalse
Question 4 True / False

A wait-for graph cycle involving three transactions typically requires aborting at least two transactions to resolve the deadlock.

TTrue
FFalse
Question 5 Short Answer

Why is a wait-for graph cycle the right model for detecting database deadlocks, and why can't simple timeouts replace it?

Think about your answer, then reveal below.