Checkpoints
By making checkpoints we can enable faster recovery and make the log files use less space.
Simple Checkpointing
This method is applicable for undo logging.
The idea is that we checkpoint the log periodically:
- Every $m$ minutes or after $t$ transaction since the last checkpoint.
- No need to undo transactions before the checkpoint.
The part before the checkpoint can be discarded from the log.
Procedure
- Stop accepting new transactions
- Wait until all active transactions finish and have written
COMMIT
orABORT
record to the log. - Flush the log to disk.
- Write a log record
<CHECKPOINT>
. - Flush the log to disk again.
- Resume accepting transactions.
Recovery with Simple Checkpoints
To complete recovery just step back through the undo log up to the checkpoint just as before.
ARIES Checkpoints
This style of checkpoints has the following two requirements:
- Undo/redo logging is used.
- Transactions do not write to buffers before they are sure they want to commit.
Procedure
- Write
<CHECKPOINT(T1, T2,…)>
in log and flush it.T1, T2,…
are the transaction in progress (i.e. not committed and not aborted).
- Write the content of the buffer to disk (i.e. output).
- Write
<END CHECKPOINT>
in log and flush it.
Recovery with ARIES Checkpoints
This is the same as recovering with an undo/redo log except:
- Only redo part of committed transactions in
T1,T2,…
after<CHECKPOINT(T1,T2,…)>
. - Then undo all of uncommitted transactions in
T1,T2,…
including before<CHECKPOINT(T1,T2,…)>
.
You must stop after having found a <CHECKPOINT(T1,T2,…)>
with corresponding <END CHECKPOINT>
and <START Ti>
for all mentioned transactions that are uncommitted.