4.2 Log records



next up previous
Next: 4.3 Shared Memory Structure Up: 4 Log Manager Interface Previous: 4.1 Log Sequence Numbers

4.2 Log records

 

The log consists of a sequence of log records. Each log record has a fixed header portion and a variable data portion. Class logrecord (header file: logrecord.h) declares the basic log record. The fixed portion of the log record contains the following fields:

  1. A magic number. This is used (as described in Section 5) to distinguish between the end of the log and the beginning of a new log record.

  2. The LSN of the log record. This need not necessarily be stored in the log record. However, we store it in the log record to make our implementation easier. Also, whenever the log record is output during debugging, the LSN can be output.

  3. The length of the log record. This is the length in bytes from the magic number field to the end of the data portion of the log record. However, users of class logrecord will only see (and set) the length of the data portion. The implementation will take care of setting this field correctly. This has been done because users of the class do not set or retrieve the fixed header portion of the log record.

The data portion of the log record is a sequence of bytes. Class logrecord does not interpret this data in any way. However, the recovery subsystem derives from this class to define several different kinds of log records [normal updates, checkpoint records, commit log records, Compensation Log Records (CLRs), etc.]. Thus, it is the recovery manager that interprets the contents of the data portion of each log record. Derivation ensures that the fixed portion of the log record (which is interpreted by class logrecord) is available in any kind of log record. Figure 1 shows an object of class logrecord and a normal update log record.

  
Figure 1: Log records. The figure at the left shows an object of the base class logrecord. The one at the right shows an object of a class derived from class logrecord. The derived class object shown corresponds to a normal update log record. For exact representation and details, see [Ramamurthy & Tsoi 95].

Class logrecord provides methods to get and set the data length. It has a method to return a pointer to the data portion of the log record. It provides read access to the LSN of the log record and write access to friends. Finally, it overloads operator << to output the log record in a human-readable format. The data portion of the log record is dumped in hex and ASCII.



next up previous
Next: 4.3 Shared Memory Structure Up: 4 Log Manager Interface Previous: 4.1 Log Sequence Numbers



ajitk@cs.wisc.edu, cjin@cs.wisc.edu