Database Reference
In-Depth Information
Log
File
TIME
Data-
base
Figure 15-28
Logging with deferred updates.
or before image is not necessary. Do not write to the data item D in the data-
base memory buffers or to the database itself yet.
3. When the transaction is about to commit, write (T, COMMIT) record on the
log file. Write all log records for the transaction to secondary storage and then
commit the transaction.
4. Perform actual updates to the database from the log records.
5. If T aborts, write (T, ABORT) record on the log file. Do not perform any writes
to the database. (Recovery process will ignore all log records.)
Figure 15-28 is a simple illustration of the deferred updates technique for trans-
action T updating two data items, A and B. Note the chronological order of the log
records and database updates.
If a failure occurs, the recovery system scrutinizes the log file to identify the trans-
actions in progress at the time of failure. Beginning from the last record in the log
file, the recovery system goes back to the most recent checkpoint record. The recov-
ery system needs to examine only the log records in the interval from that check-
point and to take action to restore the database to a consistent state.
Assume that T is possibly one of the transactions in progress. So the log records
for T will be on the log file in the interval from the most recent checkpoint to the
end of the file. The log records for T will be among the records the recovery system
will examine for recovery. It will take action based on the log records for T using
the logic indicated below:
CASE 1:
Both (T,BEGIN) and (T,COMMIT) present on the log.
Failure occurred after all log records were written.
Cannot be sure whether all database updates were completed.
However, the log file contains all records for T.
So the log records for T can be used to update the database.
USE LOG RECORDS TO UPDATE DATABASE.
DATABASE BROUGHT TO NEW CONSISTENT STATE.
CASE 2:
(T,BEGIN) present but (T,COMMIT) not present on the log.
Failure occurred before any database updates were made.
No updates were completed on database.
Search WWH ::




Custom Search