Database Basics
There are transactions T1 to T5, and one checkpoint was taken before a failure occurred. T1 started and committed before the checkpoint. T2 and T3 started before the checkpoint; T2 committed after the checkpoint but before the failure, and T3 had not committed at the time of the failure. T4 and T5 started after the checkpoint; T4 committed before the failure, and T5 had not committed. In recovery after the failure, which transactions must be rolled forward using the log?
- AT3 and T5
- BT1, T2 and T4
- CT2 and T4
Show answer and explanation
Answer: C. T2 and T4
At a checkpoint, the database pages updated in memory up to that point are written to storage, and this is recorded in the log. The updates of T1, which committed before the checkpoint, are therefore already reflected in the database and need no recovery. T2 and T4, which committed after the checkpoint but before the failure, have completed their commits, but some of their updates may not have been written to the database, so they are redone using the after values in the log (rollforward). T3 and T5, which had not committed at the time of the failure, have any partial updates written to the database undone using the before values in the log (rollback). A transaction that started before the checkpoint, such as T3, is also undone if it had not committed. Taking checkpoints shortens recovery, because the log does not have to be traced from the very beginning.
- A. T3 and T5 had not committed, so they are rolled back.
- B. T1 committed before the checkpoint, and its updates are already reflected in the database, so it is not included.
- C. Correct. T2 and T4, which committed after the checkpoint and before the failure, are rolled forward.