Consider the following sequence of two transactions on a bank account (𝐴)…
2018
Consider the following sequence of two transactions on a bank account (𝐴) with initial balance 20,000 that transfers 5,000 to another account (𝐵) and then apply 10% interest.
(i) T1 start
(ii) T1 A old=20,000 new 15,000
(iii) T1 B old = 12,000 new = 17,000
(iv) T1 commit
(v) T2 start
(vi) T2 A old = 15,000 new = 16,500
(vii) T2 commit
Suppose the database system crashes just before log record (vii) is written. When the system is restarted, which one statement is true of the recovery process?
- A.
We must redo log record (vi) to set 𝐴 to 16,500
- B.
We must undo log record (vi) to set 𝐴 to 16,500 and then redo log records (ii) and (iii)
- C.
We need not redo log records (ii) and (iii) because transaction 𝑇1 is committed
- D.
We can apply redo and undo operations in arbitrary order because they are idempotent
Attempted by 58 students.
Show answer & explanation
Correct answer: B
On restart, the recovery manager will:
REDO T1 (because its commit record is in the log).
UNDO T2 (because it has a start and an update, but no commit record in the log at the time of crash).
So after recovery:
Account A:
After T1: 20,000 → 15,000
T2’s update to 16,500 is undone, so A = 15,000
Account B:
After T1: 12,000 → 17,000 (and T2 never touched B)
✅ True statement: T1’s effects are preserved (redone if needed) and T2 is rolled back; final balances are A = 15,000 and B = 17,000.
A video solution is available for this question — log in and enroll to watch it.