The main executable is called "Mars.exe" and it makes use of the following files in its working directory:
ourlog - This contains all the log data that has been written to disk. To make things simple, the simulator currently writes all log records to disk as soon as they are made. The recovery manager usually ignores what was lost in the tail of the log when the crash occurs, so you won't have to worry about the distinction between the tail and the log on disk. In a real database, however, the log usually has a tail that is kept in memory, and some extra measures must be taken to insure that the log is written to stable storage when necessary.
master - This contains the checkpoint data used in determining the lsn from which the recovery is to start.
To start the simulator, you can double click on Mars.exe. You will then be presented with a UI containing a toolbar and the standard menu on the top row of the screen.
The toolbar contains three buttons:
- The button with the folder icon allows you to load a test file (to be explained below).
- The sideways arrow button allows you to step through the test file.
- The downward arrow button runs the test file in its entirety.
- The X button resets the database being simulated.
The simulation runs by executing a series of operations that model the behavior of a set of transactions. These operations are loaded from .mars files. There are 9 .mars file given in the Tests folder and of course you can compose your own if you want. The syntax is pretty simple and are described below. I recommend looking at the test files given as the fastest way to learn how to create them.
Operations are given with the following syntax. A semicolon is used to mark the end of a command, and spaces are used to separate arguments.
To become familiar with the code, I suggest you load either Test 1, 2, or Test 3 given in the Tests folder. The syntax is quite simple and if you step through the test files you will gain intuitive understanding how the transaction simulator works. There are comments in the given test files that tell you what the correct values of the reads should be. These are strings preceded by the # sign.