CLASS RecoveryMgr
#include <recovery_mgr.h>
This class is responsible for maintaining the consistency of the database. Through it, all changes are logged, and it is responsible for restoring the database to a consistent state after a crash. During the normal operation of the database, multiple RecoveryMgr's are instantiated, one for each active transaction. During this phase, the RecoveryMgr handles the creation of log records for all of the actions taken by its associated transaction. The RecoveryMgr provides other functions, though, that apply to the database as a whole and are not concerned with any single transactions. The most important of these is the restart function, which reads the logged data on disk and executes the Aries recovery algorithm to bring the database up to a consistent state.
Fields
RecDirtyPgTbl *_dpt;
int _current_xid;
int _mode_of_operation;
- 1 is for recovery mode, 2 is for normal mode
Methods
RecErr RollBack ( )
Executes the procedure for rolling back actions of a transaction if they abort or never complete.
RecErr Restart ( int count = -1 )
Executes the procedure for restarting the database and bringing it to a stable state where only the actions of transactions that committed remain.
RecErr Checkpoint ( )
Executes the procedure for putting a checkpoint in the log.
RecErr RecoverEarliestLSN ( lsn_t& RecLSN )
Finds the earliest LSN among all recLSN's in the page table and all min_lsn's in the Xact table and stores it in RecLSN.
RecErr GetRecoveryLSN ( int pgid, lsn_t& RecoveryLSN )
Retrieves the RecoveryLSN of page pgid and stores it into RecoveryLSN.
RecErr WriteUpdateLog ( int size, int pgid, int offset, char *old_data, char *new_data, Page* pg )
Creates an Update log record and places it into the log. The update will affect page pgid at byte position offset. The redo data will be new_data and the undo data will be old_data, both length size in bytes. The page pg will have its pageLSN updated.
RecErr WriteCommitLog ( lsn_t& lsn )
Creates a Commit log record and places it into the log. The record will have LSN equal to lsn.
RecErr WriteAbortLog ( lsn_t& lsn )
Creates an Abort log record and places it into the log. The record will have LSN equal to lsn.
RecErr _restart_analysis ( lsn_t master_lsn, RecXactTbl* xact_tbl, lsn_t &redo_lsn )
Performs the analysis phase of recovering from a crash beginning at master_lsn. The transactions that are redone are added into the transaction table xact_tbl. The analysis phase also determines the LSN of where the redo phase should begin (redo_lsn ).
RecErr _restart_redo ( lsn_t redo_lsn, RecXactTbl* xact_tbl )
Performs the redo phase of recovering from a crash beginning at LSN redo_lsn.
RecErr _restart_undo ( RecXactTbl* xact_tbl )
Performs the undo phase of recovering from a crash and follows the transaction table xact_tbl to determine which actions to undo.
RecErr _redo_update ( Page* pg, logrecord* logrec )
Recopies the data from an update log record onto page pg specified in the record.
bool keepPerformingUndo ( RecXactTbl* xact_tbl )
Determines whether of not to continue in the undo phase of recovery.
lsn_t findNextUndoLsn ( RecXactTbl* xact_tbl )
Retrieves the next Undo LSN.
lsn_t findRedoLsn ( RecXactTbl* xact_tbl )
Determines the LSN from which the redo phase begins.