Consider the following log sequence of two transactions on a bank account, with initial balance 12000, that transfer 2000 to a mortgage payment and, then apply a 5% interest (i) T1 start (ii) T1 B old = 12000 new = 10000 (ii) T1 M old = 0 new = 2000 (iv) T1 commit (v) T2 start (vi) T2 B old = 10000 new = 10500 (vii) T2 commit Suppose the database system crashed just before log record 7 is written. When the system is restarted, which one statement is true of the recovery procedure?
Consider the following log sequence of two transactions on a bank account, with initial balance 12000, that transfer 2000 to a mortgage payment and, then apply a 5% interest (i) T1 start (ii) T1 B old = 12000 new = 10000 (ii) T1 M old = 0 new = 2000 (iv) T1 commit (v) T2 start (vi) T2 B old = 10000 new = 10500 (vii) T2 commit Suppose the database system crashed just before log record 7 is written. When the system is restarted, which one statement is true of the recovery procedure? Correct Answer We must undo log record 6 to set B to 10000 and then redo log record 2 and 3
The correct answer is option 2.
Key Points
- When the database system crashes after the transactions have committed then we need to redo the log records.
- And if the database systems crash before the transactions have committed then we need to undo the log records.
From the concept, We must undo log record 6 to set B to 10000 and then redo log records 2 and 3 because the system fails before commit operations. So we need to undo active transactions(T2) and redo committed transactions (T1).
Note: Here we are not using checkpoints.
Checkpoint: Checkpoint is a mechanism where all the previous logs are removed from the system and stored permanently in a storage disk. Checkpoint declares a point before which the DBMS was in a consistent state, and all the transactions were committed.
Recovery:
When a system with concurrent transactions crashes and recovers, it behaves in the following manner.
∴ Hence the correct answer is We must undo log record 6 to set B to 10000 and then redo log record 2 and 3.