Databases Reference
In-Depth Information
If the database environment is a volatile one in which changes are made
frequently and it is common for the same piece of data to be updated several times
between backup operations, then the roll-forward operation as we have described
it may be needlessly inefficient. Instead, it may be worthwhile to sort through the
log prior to the roll-forward operation to find the last change made to each piece of
data that was updated since the last backup copy was made. Then only those final
changes need be applied to the backup copy in the roll-forward operation.
Backward Recovery
Now let's consider a different situation. Suppose that in the midst of normal
operation an error is discovered that involves a piece of recently updated data. The
cause might be as simple as human error in keying in a value, or as complicated as a
program ending abnormally and leaving in the database some, but not all, changes
to the database that it was supposed to make. Why not just correct the incorrect
data and not make a big deal out of it? Because in the interim, other programs may
have read the incorrect data and made use of it, thus compounding the error in other
places in the database.
So the discovered error, and in fact all other changes that were made to the
database since the error was discovered, must be ''backed out.'' The process is
called '' backward recovery '' or '' rollback .'' Essentially, the idea is to start with
the database in its current state (note: backup copies of the database have nothing to
do with this procedure) and with the log positioned at its last entry. Then a recovery
program proceeds backwards through the log, resetting each updated data value in
the database to its ''before'' image, until it reaches the point where the error was
made. Thus the program ''undoes'' each transaction in the reverse order (last-in,
first-out) from which it was made, Figure 11.5. Once all the data values in the
tainted updates are restored to what they were before the data error occurred, the
transactions that updated them must be rerun. This can be a manual process or, if a
transaction log was maintained as well as a change log, a program can roll forward
Current
database
(with
error
in it)
Roll
backward
program
Corrected
database
Log
(starting with
last change to
the database
and prepared
to read
backward)
F IGURE 11.5
Backward recovery
Search WWH ::




Custom Search