Recovery Management MCQs for NSCT
Recovery management is how a DBMS brings the database back to a correct state after a failure: committed work must survive (durability) and uncommitted work must vanish (atomicity). It does this with a log, checkpoints, and undo and redo passes over that log. Recovery Management is topic 11 of the Databases area, which carries 10% of the NSCT according to HEC's Areas of Competencies. In 2026 candidates averaged 42.3% in Databases, per the HEC NSCT report and APP.
Failures come in three kinds. A transaction failure (an error or a deadlock victim) affects one transaction. A system crash wipes main memory but leaves the disk. A disk (media) failure destroys stored data and needs an archival dump plus the log. Most exam questions are about system crashes.
Logs
The log is a sequential file on stable storage that records every change. Using Silberschatz's notation:
| Record | Meaning |
|---|---|
<T1 start> |
T1 has begun |
<T1, A, 100, 150> |
T1 wrote A: old value 100 (for undo), new value 150 (for redo) |
<T1 commit> |
T1 committed |
<T1 abort> |
T1's rollback is complete |
The write-ahead logging (WAL) rule says a page's log records must reach stable storage before the page itself is written to disk. A transaction counts as committed once its commit record is in the stable log (Elmasri-Navathe call this the commit point).
Buffer policies decide which operations recovery needs:
| Policy | Meaning | Consequence |
|---|---|---|
| Steal | Uncommitted pages may be written to disk | Needs undo |
| No-force | Commit does not force pages to disk | Needs redo |
So steal/no-force, the usual choice, needs both. Exam angle: deferred update is NO-UNDO/REDO, and immediate update with steal/no-force is UNDO/REDO.
Checkpoints
A checkpoint limits how much of the log recovery must read. In the simple version, the system pauses updates, writes all modified buffers to disk, and writes a <checkpoint L> record, where L lists the active transactions. A fuzzy checkpoint lets transactions continue while buffers are flushed.
After a crash, a transaction that committed before the last checkpoint needs nothing, because its pages were flushed. Exam angle: a transaction that was active at the checkpoint may have written pages before it, so its undo must read back past the checkpoint to its <T start> record.
Undo/redo
Undo writes old values, scanning the log backward. Redo writes new values, scanning forward. Textbooks give two versions:
- Elmasri-Navathe (UNDO/REDO, immediate update): redo the writes of transactions that committed after the last checkpoint, and undo every transaction with no commit record.
- Silberschatz (repeating history): from the last checkpoint, redo every logged update, losers included, while building an undo-list (the checkpoint's list, plus each started transaction, minus each one that commits or aborts). Then undo the list backward, logging redo-only records
<Ti, X, old>and finally<Ti abort>. ARIES works the same way, with analysis, redo and undo phases and compensation log records.
Both give the same final values. Take this log with a sharp checkpoint:
<T1 start>
<T1, A, 5, 9>
<T1 commit>
<T2 start>
<T2, B, 2, 4>
<checkpoint {T2}>
<T3 start>
<T3, A, 9, 11>
<T3 commit>
--- crash ---
T1 needs nothing, T3 is redone (A = 11) and T2 is undone (B = 2). Exam angle: redo must be idempotent, because recovery itself can crash and run again. Writing a stored after-image is idempotent; re-applying "A := A + 10" is not.
Common traps
- Undoing a committed transaction just because it was active at the checkpoint. If its commit record is in the log, it is a winner.
- Stopping the undo scan at the checkpoint when a loser wrote before it.
- Undoing an item to the oldest value in the log instead of the loser's own before-image, which wipes out committed work.
- Mixing up steal (needs undo) and no-force (needs redo).
Worked examples
Understanding. Which buffer-policy combination needs both undo and redo at restart? Answer: steal with no-force. Steal lets uncommitted changes reach disk (undo), and no-force lets committed changes be missing from disk (redo).
Application. The log is <T5 start>, <T5, P, 8, 12>, <T6 start>, <T6, Q, 3, 9>, <T5 commit>, then a crash. What are P and Q after UNDO/REDO recovery?
Answer: P = 12, Q = 3. T5 committed, so P is redone to 12. T6 did not, so Q is undone to its before-image 3.
Analysis. The log is <T1 start>, <T1, A, 1, 2>, <checkpoint {T1}>, <T2 start>, <T2, B, 5, 6>, <T2 commit>, <T1, C, 7, 8>, then a crash. What are A, B and C?
Answer: A = 1, B = 6, C = 7. T2 committed after the checkpoint and is redone. T1 is a loser: both its writes are undone, including A, which it wrote before the checkpoint.
Practise
The quiz below has 100 Recovery Management questions, which you can filter by tier and difficulty.
Practise: 100 questions
FAQs
What is the difference between undo and redo?
Undo reverses an uncommitted transaction's changes by writing the old values from the log, scanning backward. Redo reapplies a committed transaction's changes by writing the new values, scanning forward. Undo enforces atomicity and redo enforces durability, and a steal/no-force system needs both.
Why is a checkpoint needed in recovery?
Without one, recovery would have to scan and redo the whole log from the start. A checkpoint flushes modified pages and records the active transactions, so work committed before it is already safe on disk. Recovery can start near the last checkpoint, reading earlier records only to undo transactions that were active at it.
What is write-ahead logging?
Write-ahead logging (WAL) requires the log records describing a change to be on stable storage before the changed page is written to disk, and all of a transaction's log records to be forced before it commits. Without WAL, a crash could leave an uncommitted change on disk with no old value to undo it.
Next step
Continue with Indexing & File Organization MCQs, go back to the Databases hub, or try a timed NSCT mock test.