M.I.T. DEPARTMENT OF EECS
6.033 - Computer System Engineering | Handout 32 - April 29, 2002 |
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:
begin tid
Begin a transaction denoted by the transaction id tid
init tid account_name starting_balance
Create a new account with the given account_name and starting_balance. The first argument specifies that this operation is part of transaction tid. All other commands will take a tid as their first argument.
write tid account_number new_value
Update the account to the new_value
commit tid
Commit the transaction
checkpoint
Write a checkpoint
crash
Crash the transaction system (this is the only way to exit the program)
Print out the current state of the database
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).
./trans -reset
begin 1
init 1 student1 1000
commit 1
begin 2
init 2 student2 2000
checkpoint
begin 3
init 3 student3 3000
write 3 student3 3001
commit 3
print
crash
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
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
|