M.I.T. DEPARTMENT OF EECS

6.033 - Computer System Engineering Handout 32 - April 29, 2002

Hands-on 9: Write Ahead Log System

Intro to Trans

This hands-on assignment will give you some experience using a WAL system(as described in Chapter 8 of the course notes). You can download the system from here (if your browser displays the file in a window instead of saving it, hold down the shift key when clicking the link). The downloaded file is a Perl script named trans. Before trying to run it, change its permissions to make it executable, for example by typing:

athena% chmod 755 trans

The trans command can be run as follows:

trans [-reset]

Trans is a simple WAL system that models a bank's central database. It implements intention logging for error-recovery (without shadow files) as presented in the System R paper and the text. Run ./trans and you will be allowed to enter commands. Possible commands (which are case sensitive) are:

After you run the transaction system, and perform some transactions, two files will be created. The "LOG" file contains the log entries. The "DB" file contains the last state of the database.

You may run trans with the -reset option to clear the state of the database and start from scratch.

Since trans uses the standard input stream, you can use the system in batch mode. To do this, place your commands in a file ("cmd.in" for example) and redirect the file to trans's standard input:

athena% ./trans < cmd.in.

When using batch mode, make sure that each command is followed by a newline character (including the last one).

Using Trans

Run trans with the following commands:
  1. ./trans -reset
  2. begin 1
  3. init 1 student1 1000
  4. commit 1
  5. begin 2
  6. init 2 student2 2000
  7. checkpoint
  8. begin 3
  9. init 3 student3 3000
  10. write 3 student3 3001
  11. commit 3
  12. print
  13. crash
trans should print out what its doing, and then exit.

Examine the "DB" output file and answer the following questions:

1) When the database recovers, which accounts should be active, and what values should they contain?

2) trans prints out the database contents after you type print. Why doesn't the database show student2?

3) Can you explain why "DB" might not contain a record for student3? (Hint: The crash command does not neccessarily wait for commit to finish.)

Examine the "LOG" output file. Note that the CHECKPOINT entry lists the uncommitted TID's at that point in time. Run ./trans once again to recover the database.

4) How does trans figure out which transactions should be winners and which should be losers?

5) How would the recovery sequence differ if you had not forced a checkpoint? Why does trans use checkpoints?

6) About how long did this exercise take?



Go to 6.033 Home Page Questions or Comments: 6.033-tas@mit.edu