Hands-on 2: Write Ahead Log System (2)

Complete the following hands-on assignment. Do the activities described, and submit your solutions for following questions. Please upload your answers to Canvas in a pdf file. You are free to use either Chinese or English. Due time is 2021-11-9 23:59.

Checkpoints

Following hands-on 1, this hands-on will play with the checkpoint using wal-sys. Start wal-sys with a reset:

and run the following commands:

Note: we will ask you to crash and recover the system a few times, but you should not run the sequence commands again.

Examine the "LOG" output file. In particular, inspect the CHECKPOINT entry. Also, count the number of entries in the "LOG" file. Run wal-sys again to recover the database.

Question 1: During checkpoint, wal-sys divides actions into three types: "PENDING", "COMMITTED" and "DONE", what is the meaning of these types?

Question 2: What is the relationship between the action categories during checkpoint ("PENDING", "COMMITTED" and "DONE") and action categories during recovery ("Winners", "Losers", and "Done")?

Question 3: How many lines were rolled back? What is the advantage of using checkpoints?

Note down the action_ids of "Winners", "Losers", and "Done". Use the show_state command to look at the recovered database and verify that the database recovered correctly. Crash the system, and then run wal-sys again to recover the database a second time.

Question 4: Does the second run of the recovery procedure restore "DB" to the same state as the first run? What is this property called?

Question 5: Compare the action_ids of "Winners", "Losers", and "Done" from the second recovery with those from the first. The lists are different. How does the recovery procedure guarantee the property from Question 4 even though the recovery procedure can change? (Hint: Examine the "LOG" file).

Question 6 (Optional): Wal-sys has a hitherto unmentioned option: if you type wal-sys -undo it will perform undo logging and undo recovery. Try the above sequences again with undo logging to see what changes.