CS FundamentalsHardProduct-company MCQ pattern
Two transactions, T1 and T2, both want to update the same row. T1 acquires a shared (read) lock, then later tries to upgrade to an exclusive (write) lock on the same row, while T2 is simultaneously also holding a shared lock on that row and trying to upgrade. What classic problem can this cause?
- A. It can only happen with more than 2 transactions
- B. No problem; lock upgrades always succeed immediately
- C. A deadlock: each transaction holds a shared lock the other needs released before its own upgrade to exclusive can proceed, and neither will release its shared lock first
- D. This situation guarantees serializability automatically
Correct answer: C. A deadlock: each transaction holds a shared lock the other needs released before its own upgrade to exclusive can proceed, and neither will release its shared lock first
Lock upgrade deadlock is a classic case: T1 and T2 both hold a shared lock on the same row, and both want to upgrade to exclusive, which requires the OTHER transaction's shared lock to be released first. Neither will give up its own shared lock (each is also waiting to upgrade), so both wait forever — a two-transaction deadlock caused purely by simultaneous lock upgrades.
More DBMS and SQL questions
- A query uses SELECT ... FOR UPDATE to explicitly lock the rows it reads within a transaction. What is the main purpose of this, compared…
- A long-running read-only transaction under snapshot isolation sees a consistent view of the database as of its start time, even while…
- A relation R(A, B, C) has the single functional dependency A → B (C is independent, with no FD at all involving it, and no candidate key…
- A table's clustered index key is UUID-based (a random 128-bit value) rather than a sequential integer. What problem does this commonly…
- After a crash, the analysis phase of ARIES recovery scans the log forward from the last checkpoint to rebuild the transaction table…
- A relation Enrollment(studentid, courseid, semester, grade) has candidate key (studentid, courseid, semester). A functional dependency…