WE will use log and checkpoints to recover
Transaction roll back
If we try to rollback transaction Ti
Scan the log backward
We will try to scan each log record <Ti, Xj, V1, V2> that belongs to Ti.
Then we will write V1(the old value) to Xj.
Write a REDO-only log <Ti, Xj, V1> to the log. This is called the compensating log. ( we don’t need to store both old and new value here since during a undo, because if system crash during recovery, we only need to REDO these logs to finish the UNDO).
Once we found
Recovery after a crash
Scan the log forward from the last checkpoint. and replay all transactions.
This replay include both rollback and uncommitted transaction.
We also need to determine the list of incomplete transactions. They are either in
Rollback all transactions in the undo-list by scanning the log backward from the end
If DB finds a transaction Ti in the undo list, it will rollback to old value.
When DB sees a
Undo terminate when we have seen all Ti’s
This will allow updates to start once
If a crash happened before all pages in the modified buffers are written to disk, we might have an incomplete checkpoint.
We will deal with this by storing a fixed position last-checkpoint ptr on disk and we will not update this ptr when we first write