Sample questions
Question 1Easy
Which type of failure loses the contents of main memory but not the disk?
- Disk head crash
- Media failure
- System crash (e.g. power failure)
- Logical error in a transaction
Answer: C. System crash (e.g. power failure)
Explanation
Volatile buffers are lost; the log and database on disk survive and are used for recovery.
Step-by-step solution
- A power failure or OS crash wipes main memory (the buffer pool).
- Disks keep their contents.
- This is a system crash; recovery uses the log on disk to undo and redo.
Why the other options are wrong
- A. A head crash destroys the disk itself.
- B. Media failure is loss of non-volatile storage.
- D. A logical error affects one transaction, not main memory.
Tip: System crash loses RAM; media failure loses the disk.
Question 2Easy
Redo in recovery is applied to transactions that:
- Were rolled back by the user
- Are still waiting for locks
- Committed but whose changes may not have reached disk
- Never started
Answer: C. Committed but whose changes may not have reached disk
Explanation
Redoing committed changes from the log preserves durability.
Step-by-step solution
- A committed transaction's changes may still be only in the buffer at the crash.
- Durability says committed changes must survive.
- So recovery redoes them from the after-images in the log.
Why the other options are wrong
- A. Rolled-back transactions are already undone.
- B. Waiting transactions had not committed, so they are undone.
- D. A transaction that never started has nothing to redo.
Tip: Redo protects durability; undo protects atomicity.
Question 3Easy
Where must the transaction log be kept so that it survives a system crash?
- In CPU registers
- Only in the buffer pool
- Stable (non-volatile) storage
- In the query cache
Answer: C. Stable (non-volatile) storage
Explanation
Recovery reads the log after restart, so it must be written to storage that survives power loss, often duplicated on separate disks.
Step-by-step solution
- After a crash, recovery reads the log.
- Memory, caches and registers are lost on power failure.
- So the log must be on stable storage, often duplicated on separate disks.
Why the other options are wrong
- A. CPU registers are volatile.
- B. The buffer pool is in main memory and is lost.
- D. Query caches are in memory.
Tip: The log must survive what the data might not.
Question 4Easy
Undo in recovery is applied to transactions that:
- Committed after the last checkpoint but before the crash
- Only read data
- Committed before the last checkpoint
- Had not committed at the time of the crash
Answer: D. Had not committed at the time of the crash
Explanation
Their partial effects must be removed to preserve atomicity.
Step-by-step solution
- At the crash, some transactions had not committed.
- Some of their changes may already be on disk.
- Atomicity requires removing them, so undo is applied to uncommitted transactions.
Why the other options are wrong
- A. Committed transactions are redone, not undone.
- B. Read-only transactions changed nothing.
- C. Committed work is kept; before the checkpoint it is already safe on disk.
Tip: Uncommitted means undo; committed means redo.
Question 5Medium
In a log record <T, X, V1, V2>, which value is used for undo and which for redo?
- V1 for both
- V2 for undo, V1 for redo
- V1 for undo, V2 for redo
- V2 for both
Answer: C. V1 for undo, V2 for redo
Explanation
V1 is the old (before) value and V2 the new (after) value; undo restores the old value and redo reapplies the new value.
Step-by-step solution
- V1 is the old value (before-image).
- V2 is the new value (after-image).
- Undo restores V1; redo reapplies V2.
Why the other options are wrong
- A. Redo needs the new value.
- B. This is reversed.
- D. Undo needs the old value.
Tip: Old value for undo, new value for redo.
Question 6Medium
A buffer policy of STEAL with NO-FORCE requires the recovery algorithm to support:
- Neither undo nor redo
- Only redo
- Only undo
- Both undo and redo
Answer: D. Both undo and redo
Explanation
STEAL lets uncommitted changes reach disk (needs undo). NO-FORCE lets committed changes stay only in memory at commit (needs redo).
Step-by-step solution
- STEAL: uncommitted pages may be written to disk, so undo is needed.
- NO-FORCE: committed pages need not be on disk at commit, so redo is needed.
- Both undo and redo are required.
Why the other options are wrong
- A. That would be NO-STEAL with FORCE.
- B. Redo only is NO-STEAL with NO-FORCE.
- C. Undo only is STEAL with FORCE.
Tip: STEAL -> undo; NO-FORCE -> redo.
Question 7Medium
During recovery, why must redo operations be idempotent?
- Idempotence speeds up the analysis pass
- Undo operations rely on redo having been applied exactly once per record
- A crash during recovery may cause the same redo to be applied again
- Redo is only done once per log record
Answer: C. A crash during recovery may cause the same redo to be applied again
Explanation
If recovery itself crashes, it restarts and repeats work; applying a redo twice must give the same result as applying it once.
Step-by-step solution
- A crash can happen during recovery itself.
- Recovery then restarts and replays the same log records.
- Applying a redo twice must give the same result as once: idempotence.
Why the other options are wrong
- A. Idempotence is about correctness, not speed.
- B. Undo does not depend on redo being applied exactly once.
- D. Redo may be applied more than once.
Tip: Redo may run twice; it must be safe to repeat.
Question 8Medium
In the undo phase of recovery, the log is scanned in which direction?
- In random order
- Backward, from the end of the log
- Forward, from the last checkpoint
- Forward, from the beginning
Answer: B. Backward, from the end of the log
Explanation
Undoing in reverse order restores the oldest before-image last, which is the correct original value.
Step-by-step solution
- A transaction may have changed the same item several times.
- The correct original value is the oldest before-image.
- Scanning backward from the end of the log restores the oldest value last, so it is the one that remains.
Why the other options are wrong
- A. Random order could leave an intermediate value.
- C. Forward is the direction for redo.
- D. Forward order would leave a newer before-image in place.
Tip: Redo goes forward, undo goes backward.
Question 9Hard
Log: <T1 start> <T1 commit> <T2 start> <checkpoint {T2}> <T3 start> <T3 commit> <T4 start> <T2 commit> <T5 start>, then a crash. With immediate update and this checkpoint, which transactions are redone and which undone?
- Redo T3; undo T2, T4, T5
- Redo T1, T2, T3; undo T4, T5
- Redo T2, T3, T4; undo T5
- Redo T2, T3; undo T4, T5
Answer: D. Redo T2, T3; undo T4, T5
Explanation
T1 committed before the checkpoint, so it needs nothing. T2 (active at the checkpoint) and T3 committed after it, so they are redone. T4 and T5 have no commit record, so they are undone.
Step-by-step solution
- T1 committed before the checkpoint: already on disk, ignore.
- T2 (active at checkpoint) and T3 committed after it: redo.
- T4 and T5 have no commit: undo.
Why the other options are wrong
- A. T2 committed before the crash, so it is redone, not undone.
- B. T1 committed before the checkpoint, so no redo is needed.
- C. T4 never committed.
Tip: Before checkpoint and committed: ignore. After: redo if committed, undo if not.
Question 10Hard
Which is a well-known disadvantage of shadow paging?
- Data becomes fragmented and old pages need garbage collection
- It requires a full checkpoint to be written after every single update
- It needs both undo and redo logs
- It cannot provide atomicity
Answer: A. Data becomes fragmented and old pages need garbage collection
Explanation
Updated pages are written to new locations, destroying physical clustering, and unreferenced old pages must be reclaimed.
Step-by-step solution
- Updated pages are written to new locations.
- Related data gets scattered across the disk.
- Old pages must be garbage collected after commit.
Why the other options are wrong
- B. Shadow paging does not need a checkpoint after every update.
- C. It needs no undo/redo log in its basic form.
- D. It does provide atomicity through the pointer switch.
Tip: Shadow paging costs: fragmentation and garbage collection.
Practise all 22 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →