Project 4

Transaction Simulation & Crash Recovery

Due Date: Monday, November 17, 1997

Introduction

In this assignment you will complete certain parts of a simple database engine. The database is modeled very simply, and runs by executing a series of transaction operations given to it by the user. Each transaction performs a series of reads and writes on the pages of the database, and can commit or abort at any time.

The simulator keeps a recovery manager module that keeps a log of the database's activity. At any point in time, the database may crash (specifically, when it encounters a special command to induce a crash). The recovery manager then performs a restart to restore the database to a correct state, using the Aries recovery algorithm.

The Transaction Simulator

The transaction simulator works just like a mini-database. There is a series of pages stored in a file on disk, accessed through a buffer. Transactions are modeled as a sequence of reads and writes to the pages of the database. A log is kept of all changes to database pages, with WAL used to insure that committed transactions are fully represented by the log as written to stable storage. Checkpoints can be inserted at will.

The input comes either directly from the user or from an input file in a predetermined format. The syntax for issuing commands to the simulator is discussed in Getting Started with the Simulator.

A breakdown of the major components follows:

The recmgr_tab.c module is responsible for parsing the input. It is computer generated, and not very fit for modification. Don't worry too much about what it does; just know that it takes one command at a time from the standard input (which we might have redirected to point to a file) and converts it into a database operation. If you'd like to modify it in any way, let me know and I'll see what I can do.

The handle.cpp module contains the standalone functions for performing the commands. There's one for each operation, and are the "top-level" functions that are first called when an operation is done. The functions in handle.cpp are the functions that will call the Recovery Manager functions that you will be finishing, and will pass in the relevant data about the operations.

Your Mission

You will implement various pieces of the recovery module. Specifically, you will implement the functionality to handle the most basic and common of transactions, the write. You must add code to the logging mechanism so that writes (also called updates) to the pages of the DB are reflected in the log, and then implement those parts of the restart mechanism that deal specifically with those log entries to restore the database to a consistent state.

The code you will write belongs in these modules:

What to Hand In

  1. A listing of all source files you modified or added (though I doubt you'll have to add any).
  2. The output, with debugging enabled, of your code when run on tests that demonstrate the full range of functionality. Something like Test 7 would be suitable, with enough detailed output so that I can see the steps taken by the recovery manager to restore the database after a crash. The debugging code already written (mainly PrintLogRec) and included in the code should be sufficient for this purpose.
  3. An explanation of your code, including any assumptions made, and any deviations from the standard Aries recovery scheme given in the text. Include some comments on the design of the recovery manager, including problems you saw and ways to improve the code.

Grading

  1. 70% Correctness
  2. 20% Documentation
  3. 10% Coding Style

Questions

All questions should be directed to Patrick McClanahan. or the staff Good luck!