GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 20

Undo and redo after a crash

Database Management Systems · Recovery & Logging · Full GATE CSE 2006 paper

GATE 2006, Q20 1 mark · MCQ
Report issue

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