Checkpoint
- The checkpoint is a type of mechanism where all the previous logs are removed from the system and permanently stored in the storage disk.
- The checkpoint is like a bookmark. While the execution of the transaction, such checkpoints are marked, and the transaction is executed then using the steps of the transaction, the log files will be created.
- When it reaches the checkpoint, then the transaction will be updated in the database, and till that point, the entire log file will be removed from the file. Then the log file is updated with the new step of the transaction till the next checkpoint and so on.
- The checkpoint is used to declare a point before which the DBMS was in a consistent state, and all transactions were committed.
Recovery using Checkpoint
In the following manner, a recovery system recovers the database from this failure:
- The recovery system reads log files from the end to the start. It reads log files from T4 to T1.
- The recovery system maintains two lists, a redo-list, and an undo list.
- The transaction is put into a redo state if the recovery system sees a log with <Tn, Start> and <Tn, Commit> or just <Tn, Commit>. In the redo-list and their previous list, all the transactions are removed and then redone before saving their logs.
- For example: In the log file, transactions T2 and T3 will have <Tn, Start> and <Tn, Commit>. The T1 transaction will have only <Tn, commit> in the log file. That's why the transaction is committed after the checkpoint is crossed. Hence it puts T1, T2, and T3 transactions into the redo list.
- The transaction is put into undo state if the recovery system sees a log with <Tn, Start> but no commit or abort log is found. In the undo list, all the transactions are undone, and their logos are removed.
- For example Transaction, T4 will have <Tn, Start>. So T4 will be put into undo list since this transaction is not yet complete and failed.
0 comments:
Post a Comment
Thanks