GATE / CS ARCHIVE

SIMILAR QUESTIONS / DATABASE MANAGEMENT SYSTEMS

Classify logged transactions for undo and redo

2 questions solved the same way, newest first. Back to Database Management Systems

How these are solved

Use crash/checkpoint and commit positions to distinguish committed effects needing redo from unfinished effects needing undo. Logging/checkpoint assumptions remain part of each stem.

2 marks · MCQ
Report issue

Recovery & Logging

Question 39, GATE 2015: Simple checkpoint log: startT4; writeT4 y2→3; startT1; commitT4; writeT1 z5→7; checkpoint; startT2; writeT2 x1→9; commitT2; startT3; writeT3 z7→2; crash. Choose undo/redo lists: A undoT3, T1/redoT2; B same undo/redoT2, T4; C no undo/redo all four; D undoT3, T1, T4/redoT2.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

T4 committed before the completed checkpoint and needs no redo. T2 committed after it and must be redone. T1 and T3 are incomplete at crash and must be undone, including T1 begun before the checkpoint. Hence Undo{T3, T1}, Redo{T2}, A, under the stated simple checkpoint model.

Classify transactions by completion relative to the checkpoint and crash. T4 committed before the completed checkpoint, so the simple model treats its effects as safely checkpointed. T2 committed later and needs redo to ensure its updates appear. T1 and T3 have no commit record, so their changes must be undone, even though T1 started before the checkpoint. Starting before a checkpoint does not automatically make an unfinished transaction safe. More elaborate recovery protocols may scan different worklists, but this is the stated simple model.

Original paper, page 39 · Answer key

1 mark · MCQ
Report issue

Undo and redo after a crash

Recovery & Logging

Question 20, GATE 2006: A bank account initially has balance 12000. A transaction transfers 2000 to mortgage M, then another applies 5% interest. Log records are:
1 T1 start
2 T1 B old=1200 new=10000
3 T1 M old=0 new=2000
4 T1 commit
5 T2 start
6 T2 B old=10000 new=10500
7 T2 commit
The old value 1200 in record 2 is printed despite the narrative's 12000. The system crashes just before record 7 is written. Which recovery assertion is true?
Options:
(A) Redo record 6, setting B=10500
(B) Undo record 6 to B=10000, then redo records 2 and 3
(C) Records 2 and 3 need not be redone because T1 committed
(D) Redo and undo can be performed in arbitrary order because they are idempotent
Tap to enlarge
Your answer
Answer & solution

Answer: B under undo-redo logging (no official key was published)

1. T1 has a commit record, whereas T2 does not. Undo T2’s balance change to 10000 and ensure T1’s balance/mortgage changes 10000 and 2000 are redone, B.

2. Commit does not necessarily force all modified pages to disk in undo-redo logging; idempotence does not allow arbitrary ordering of conflicting log actions. The printed old balance in record 2 is 1200 although the narrative says 12000.

3. That inconsistency does not change the committed new balance or this recovery conclusion, but it is not silently corrected.

4. Teaching check: Recovery distinguishes a transaction whose commit record reached the log from one whose commit record never did. Redo protects committed effects that may not yet be on disk; undo removes effects from incomplete transactions that may already have reached disk. A commit record is therefore not proof that every data page was forced.

Original paper, page 3