Information Technology Reference
In-Depth Information
the state of T to “backward-rolling” in the transaction record of T in the active-
transaction table and appends the log record
h
T; A
i
to the log buffer. Next the log is
scanned in reverse chronological order, starting from the end and going backwards,
via the
U
NDO
-N
EXT
-LSN
chains, towards the beginning, examining the log records
for forward-rolling updates. The next log record to be examined is always the one
whose
LSN
is the same as the currently greatest
U
NDO
-N
EXT
-LSN
value in the active-
transaction table.
Whenever an update log record
h
T; o; p;
N
x; n
i
is encountered in the log scan, the page p is fixed and write-latched, and the undo
action o
1
Œ
N
x is executed on the page p
0
that currently covers the key of the target
tuple of the action (given in
N
x).
The undo action is executed in the same manner as the undo action of a single
backward-rolling transaction or of a forward-rolling transaction doing a partial
rollback, during normal transaction processing. As explained in Sect.
4.3
, the undo
action is first attempted physically, but if this fails, it is done logically. If the page p
mentioned in the log record as the original target page of the forward-rolling action
oŒ
N
x still covers the key of the tuple and the undo action o
1
Œ
N
x can be executed
on page p,thenp is the target page p
0
of the undo action, and the undo action
is physical; otherwise p is unlatched and unfixed, and the undo action is executed
logically (see Algorithms
4.7
and
4.9
).
As explained in Sect.
3.4
, the undo action is logged with a redo-only log record
with
m
0
:
h
T; o
1
;p
0
;
N
x
0
;n
i
,
where
N
x
0
is the part of the arguments
N
x needed for redoing the undo action (recall
the log records (
3.11
)-(
3.13
)). The
LSN
m
0
is stamped into the
P
AGE
-LSN
field of
page p
0
, and the page is unlatched and unfixed. The
U
NDO
-N
EXT
-LSN
of T is set
back to n in the active-transaction table. The next log record to be examined is the
one whose
LSN
is now the greatest
U
NDO
-N
EXT
-LSN
of the transaction records in the
active-transaction table.
Whenever a log record
h
T; B
i
is encountered, we conclude that transaction T has
been completely rolled back; hence,
h
T; C
i
is written to the log, the log is flushed
onto disk, and the transaction record for T is deleted from the active-transaction
table. The undo pass ends when there are no longer any transactions left in the
active-transaction table.
The normal steal-and-no-force and write-ahead-logging policies are applied
during the undo pass. The algorithm for the undo pass is given as Algorithm
4.16
.