Consider the following log sequence of two transactions on a bank account, with initial balance that transfer to a mortgage payment and then apply a interest.
- T1 start
- T1 B old new
- T1 M old new
- T1 commit
- T2 start
- T2 B old new
- T2 commit
Suppose the database system crashes just before log record is written. When the system is restarted, which one statement is true of the recovery procedure?
View worked solution
Answer: B
During database recovery after a crash, the system scans the log to identify the status of transactions at the time of the crash:
- Transaction : Both
T1 startandT1 commitare present in the log. Since committed before the crash, its actions must be redone to guarantee durability. This means redoing log records 2 and 3. - Transaction : Only
T2 startis present in the log (the crash occurred beforeT2 commitcould be written). Since was active/uncommitted at the time of the crash, its actions must be undone to maintain database consistency. This means undoing log record 6, which restores the value of to its old value of .
Therefore, the recovery procedure must undo log record 6 (setting to ) and redo log records 2 and 3, which matches Option B.
Free practice · Your answers on this page are not saved.
