|
let me take over this problem
before understanding forward phase and backward phase, we need to understand the background of recovery.
there are two LSN are important: MinBuffLSN and LowTranLSN:
minbufflsn
LSN of the log record that is the oldest change made to a data page that is still in the buffer pool (ie. the change has not been written to disk yet, and if the database crash now, the change, and any subsequent changes on that page, will be lost). It moves up when that page is written to disk, either by page cleaner or by agent when the bufferpool memory need to be used to store another data page (ie. page stealing).
lowtranlsn
LSN of the first log record written by the oldest uncommitted transaction. It only moves up when the oldest transaction commits/aborts. Oldest is is ordered by the time transactions write their first log records, not the UOW start time reported by database monitor.
----(Log Control Data on Disk)-----------Oldest Changed Page (minbufflsn)------Oldest Uncommitted Transaction(lowtranlsn)------CRASH!!!!!------->
note: lowtranlsn may siting before minbufflsn
at the time of a failure, such as a loss of power, there may be a number of changes to the database which have updated data in the bufferpool. This data may:
1) not have been written to disk and not have been committed.
2) note have been written to disk but have been commiteted.
3) have been written to disk and have been commiteted.
when db2 is restarted, the db2 log files are used to perform a crash recovery of the database. the crash recovery ensures that the database is brought back to a consistent state. All committed transactions are applied to the database, and all uncommitted transaction are not applied to the database.
By taking the lower of lowtranlsn and minbufflsn, db2 can determine where to start processing (by LSN) with in the log files after crash. all records before this point have been commiteted (log record written) and have had their data pages written to disk aslo, and will not need to be processed. db2 will then read all records from this point forward in the log files and reapply each change.
this is refrerred to as the "REDO" phase of recovery. (forward phase)
once all of the log records have been reapplied, all uncommitted transactions are rolled back. this is referred as the "UNDO" phase of recovery. (backward phase)
at this point the database is consistent: all transactions that completed before crash have been redone, and all active transactions have been rolled back.
i hope this can help you a bit
good luck |
|