Database Reference
In-Depth Information
to identify the deletion of a record. For an Insert action, no before image appears in the log because the data did
not exist prior to the action. Similarly, for a Delete action, no after image appears in the log.
The sample log shows, for example, that transaction 2 began at 8:01. The database changes to complete
the transaction occurred at 8:02 (order record 21700 inserted), 8:05 (the first order line record inserted),
8:09 (the second order line record inserted), 8:11 (the first part record updated), 8:12 (the second part record
updated), 8:14 (customer record 282 updated), and 8:16 (rep record 35 updated). At 8:17, the transaction
was committed. During this same time span, the other three transactions were also committed.
Forward Recovery
How is the log used in the recovery process? Suppose a catastrophe destroys the database just after 8:11. In
this case, the recovery of the database begins with the most recent database backup from the previous even-
ing at 10:00. As shown in Figure 7-12, the DBA copies the backup over the live database. Because the data-
base is no longer current, the DBA executes a DBMS recovery program that applies the after images of
committed transactions from the log to bring the database up to date. This method of recovery is called
forward recovery.
244
Copy
Most recent
database
backup
Premiere
Products
database
1. DBA copies the most
recent database backup over
the live database
DBMS forward
recovery feature
Log
(after images)
2. DBMS forward recovery
feature uses the log to apply
after images for committed
transactions
FIGURE 7-12
Forward recovery
In its simplest form, the recovery program in chronological order copies the after image of each record in
the log over the actual record in the database. You can improve the recovery process by realizing that if a
record was updated 10 times since the last backup, the recovery program copies the after image records 10
times over the database record. Thus, in reality, the first nine copies are unnecessary. The 10th after image
includes all the updates accomplished in the first nine. Thus, you can improve the performance of the recov-
ery program by having it first scan the log and then apply the last after image.
Q&A
Question: In the preceding scenario, which transactions in the sample log shown in Figure 7-11 does the
recovery program use to update the restored database?
Answer: The catastrophe occurred just after 8:11. Because the recovery program applies transactions com-
mitted before the catastrophe, the program applies only transactions 1 and 3. These two transactions com-
mitted before 8:11, at which point the DBMS was still processing transactions 2 and 4.
 
 
Search WWH ::




Custom Search