DBMS MCQs - Concurrency Control, Serializability and Recovery (Set 5)

DBMS MCQs - Concurrency Control, Serializability and Recovery (Set 5) - CodingHumans

This set covers transaction management: schedules, serializability, recoverability, locking and timestamp protocols, deadlock handling and crash recovery. Most questions give you a schedule or a log to analyse, which is the pattern used in GATE and university exams, and the concepts are also common in backend and database interviews.

How to practise: read each question and tap the option you think is correct. You will see right away whether you got it, along with a short explanation, and your score is tracked at the bottom of the screen. This set has 18 questions.

Topics covered in this set

  • Schedules, conflicts and precedence graphs
  • Conflict and view serializability
  • Recoverable and cascadeless schedules
  • 2PL, strict 2PL, timestamp ordering and Thomas write rule
  • Deadlock prevention, log-based recovery, ARIES and shadow paging

DBMS MCQs with answers and explanations

Q1. A schedule in which the operations of each transaction are executed one after another, with no interleaving between transactions, is called:

a) A serial schedule

b) A concurrent schedule

c) A cascadeless schedule

d) A recoverable schedule

Q2. Which pair of operations from different transactions does NOT conflict?

a) W1(X) and R2(X)

b) R1(X) and W2(X)

c) R1(X) and R2(X)

d) W1(X) and W2(X)

Q3. A schedule is conflict serializable if and only if its precedence graph:

a) Has no edges

b) Is acyclic

c) Is strongly connected

d) Has exactly n - 1 edges for n transactions

Q4. Consider the schedule S below. Which statement is correct?

S: R1(A), W2(A), R2(B), W1(B)

a) It is conflict serializable and equivalent to T1 then T2

b) It is conflict serializable and equivalent to T2 then T1

c) It is a serial schedule

d) It is not conflict serializable because the precedence graph has the cycle T1 -> T2 -> T1

Q5. What is the equivalent serial order of the following conflict serializable schedule?

S: R2(B), R1(A), W1(A), R3(B), R2(A), W3(B), W2(A)

a) T2, T1, T3

b) T1, T2, T3

c) T2, T3, T1

d) It is not conflict serializable

Q6. A schedule that is view serializable but NOT conflict serializable must contain:

a) Blind writes

b) A deadlock

c) A cascading rollback

d) A read-only transaction

Q7. Which condition defines a recoverable schedule?

a) No two transactions ever read the same data item

b) Every write of a transaction is preceded by a read of the same item

c) Whenever Tj reads a value written by Ti, Ti commits before Tj commits

d) The schedule contains no blind writes

Q8. How is the following schedule classified?

S: W1(X), R2(X), C2, C1

a) Recoverable and cascadeless

b) Cascadeless but not recoverable

c) Strict

d) Not recoverable

Q9. How is the following schedule classified?

S: W1(X), R2(X), C1, C2

a) Recoverable but not cascadeless

b) Cascadeless

c) Not recoverable

d) Strict

Q10. What does basic two-phase locking (2PL) guarantee?

a) Freedom from deadlock

b) Conflict serializability

c) Cascadeless schedules

d) Freedom from starvation

Q11. How does strict two-phase locking differ from basic two-phase locking?

a) It allows lock upgrades from shared to exclusive

b) It requires all locks to be acquired before the transaction starts

c) It releases all shared locks before acquiring any exclusive lock

d) It holds all exclusive locks until the transaction commits or aborts

Q12. Under the basic timestamp ordering protocol, TS(T1) = 10 and TS(T2) = 20. T2 has already read X, so R-timestamp(X) = 20. Now T1 issues write(X). What happens?

a) The write is executed and W-timestamp(X) becomes 10

b) The write is ignored and T1 continues

c) T1 is rolled back and restarted with a new timestamp

d) T2 is rolled back

Q13. Under timestamp ordering with Thomas write rule, W-timestamp(X) = 30 and R-timestamp(X) = 15. Transaction T with TS(T) = 20 issues write(X). What happens?

a) The write is ignored and T continues

b) T is rolled back

c) The write is performed and W-timestamp(X) becomes 20

d) T waits until the transaction with timestamp 30 commits

Q14. Under the wait-die scheme, T1 (TS = 5) requests an item locked by T2 (TS = 10), and T3 (TS = 15) requests an item locked by T1. What happens?

a) T1 is rolled back and T3 waits

b) Both T1 and T3 wait

c) T2 is rolled back and T3 waits

d) T1 waits and T3 is rolled back

Q15. Under the wound-wait scheme, T1 (TS = 5) requests an item locked by T2 (TS = 10). What happens?

a) T1 waits for T2 to release the lock

b) T2 is rolled back (wounded) and T1 gets the lock

c) T1 is rolled back

d) Both transactions are rolled back

Q16. A system uses immediate database modification with checkpoints. The log at the time of the crash is shown. Which transactions are redone and which are undone during recovery?

<T1 start>
<T1, A, 10, 20>
<T1 commit>
<T2 start>
<T2, B, 5, 15>
<checkpoint {T2}>
<T3 start>
<T3, C, 1, 2>
<T3 commit>
<T4 start>
<T4, D, 7, 8>
--- crash ---

a) Redo T1 and T3; undo T2 and T4

b) Redo T2 and T3; undo T4

c) Redo T3; undo T2 and T4

d) Undo T1, T2, T3 and T4

Q17. In which order does the ARIES recovery algorithm perform its three passes after a crash?

a) Analysis, Redo, Undo

b) Undo, Redo, Analysis

c) Redo, Analysis, Undo

d) Analysis, Undo, Redo

Q18. Which statement about shadow paging is correct?

a) It needs an undo log but no redo log

b) It needs no undo or redo log, because the shadow page table keeps the pre-transaction state until commit switches the pointer to the new page table

c) It keeps related data pages physically together, so it causes no data fragmentation

d) It is the recovery technique used inside ARIES

Quick revision notes

  • Two operations conflict if they are from different transactions, on the same item, and at least one is a write.
  • Conflict serializable <=> precedence graph is acyclic; topological order gives the serial order.
  • Every conflict serializable schedule is view serializable; the reverse needs blind writes.
  • Strict ⊂ cascadeless ⊂ recoverable; recoverable means a reader commits only after the writer commits.
  • Basic 2PL guarantees conflict serializability but not freedom from deadlock or cascading rollback; strict 2PL holds X-locks till commit.
  • Basic TO: abort T if TS(T) < R-TS(X) on write; Thomas write rule ignores a write if TS(T) < W-TS(X).
  • Wait-die: older waits, younger dies. Wound-wait: older wounds younger, younger waits.
  • Write-ahead logging: log records must reach stable storage before the corresponding data page is written.

Frequently asked questions

Why is conflict serializability preferred over view serializability in practice?

Testing view serializability is NP-complete, while conflict serializability can be checked in polynomial time using a precedence graph. Locking and timestamp protocols are also designed to guarantee conflict serializability directly.

What is the difference between deadlock prevention and deadlock detection?

Prevention schemes such as wait-die and wound-wait use timestamps to ensure a cycle of waiting never forms, at the cost of some unnecessary rollbacks. Detection allows deadlocks to occur, finds cycles in a wait-for graph, and rolls back a victim to break them.

Why are checkpoints used in log-based recovery?

Without checkpoints the recovery manager would have to scan the entire log and possibly redo work that is already on disk. A checkpoint flushes modified pages and records the active transactions, so recovery only needs to look at the log from the last checkpoint onwards (plus the active transactions' earlier records for undo).

Comments

Answered 0/0Correct 0