Information Technology Reference
In-Depth Information
4.8
Redo Pass for Do-Redo-Undo Recovery
The redo pass “repeats history,” that is, restores the state of the database as it
was when the failure occurred. More specifically, the redo pass brings the physical
database (and hence also the logical database) to the state that existed when the most
recent log record surviving on the log disk was written.
The state of the database is reconstructed from the disk version of the physical
database and the log found on the log disk. The log is scanned starting from the
R EDO -LSN to the end of the log, and the updates recorded in the log that are not found
in the disk versions of the database pages are redone. Updates by active transactions
are also redone, even though these transactions will eventually be rolled back in the
undo pass of recovery.
While scanning the log, if a log record
n Wh T; o; p; N x; n 0 i
for a forward-rolling update action, or a log record
n Wh T; o 1 ;p; N x; n 0 i
for a backward-rolling undo action, on page p by a transaction T is encountered,
the LSN n of the log record is compared with R EC -LSN .p/.Ifn< R EC -LSN .p/,we
know that the update logged with LSN n is in the page p, so that the page need not
be latched at all and the log record can be skipped (Fig. 4.4 a).
On the contrary, if n R EC -LSN .p/, the update may or may not be in the page.
Therefore, the page must be fixed and write-latched and its P AGE -LSN be examined.
If n P AGE -LSN .p/, the update is there, so the page is unlatched and unfixed, and
the log record is skipped (Fig. 4.4 b). Otherwise n> P AGE -LSN .p/, indicating that
the update is not in the page. In this case, we perform the logged action oΠN x (or,
respectively, o 1 ΠN x)onpagep, advance P AGE -LSN .p/ n, and unlatch and unfix
page p (Fig. 4.4 c).
In the cases when n R EC -LSN .p/ (Fig. 4.4 b, c), page p,afterbeingfixedand
write-latched, is found unmodified, R EC -LSN .p/ can be advanced by setting in the
modified-page table:
R EC -LSN .p/ max f R EC -LSN .p/; P AGE -LSN .p/ C 1 g ,
where the value “ P AGE -LSN .p/ C 1” represents the least LSN value greater than the
value P AGE -LSN .p/. Because in this situation the contents of the disk and buffer
versions of the page are the same and because the page thus has all updates
with LSN supto P AGE -LSN .p/, the above assignment is correct, preserving ( 3.1 ):
R EC -LSN .p/ M ODIFIED -LSN .p/.
This updating of the R EC -LSN s is essential for accelerating the redo pass, because
P AGE -LSN .p/ may be much greater than the LSN of the log record being scanned.
Once the disk version of page p has been fetched from disk to the buffer and its
P AGE -LSN examined and found to be greater than the R EC -LSN .p/ currently recorded
in the modified-page table, R EC -LSN .p/ is advanced to P AGE -LSN .p/ C 1,sothatpage
Search WWH ::




Custom Search