Database Reference
In-Depth Information
Log
File
CUSTOMER
ACCOUNT
RECORD
COMPANY
CASH
RECORD
DB in
inconsistent
state
Balances after failure
$500
$100000
Recovery
(making transaction atomic) :
Option 1- backout DB updates
+
500
DB stays in
prior
consistent
state
Balances at end of recovery
$1000
$100000
Option 2- complete all DB updates
+ 500
DB brought
to new
consistent
state
Balances at end of recovery
$500
$100500
Figure 15-27
Log file.
about the intended updates, you can do one of two things. You can either back out
the effects of partial update and restore the database to its prior consistent state or
you can apply the incomplete update and move the database forward to a new con-
sistent state. But where can you get the information about the intended updates?
What if you store this information in another file apart from the database itself?
The transaction can write information about the update on this file in addition to
updating the database. Such a file is called a log, journal, or trail file. Figure 15-27
demonstrates the use of a log file for the transaction shown in Figure 15-26.
Logging is a principal component in the database recovery process. Most data-
base systems adopt log-based techniques for recovery from failures. The log file
keeps track of all operations of transactions that change values of data items in a
database. The file is kept on secondary storage such as a disk and used for recov-
ery from failures. Initially, the recent log records are kept in main memory and then
forced out to secondary storage. By this approach, processing of each transaction
need not wait on the I/O to write log records to disk. Periodically, the contents of
the log file on disk are transferred to a tape or other archival medium for safe-
keeping. Let us examine the types of records written on the log file.
Writing Log File Records Every log record receives a unique identifier called
the log sequence number to identify the specific transaction. Usually, log sequence
identifiers are in increasing order, as required by some recovery techniques. Each
record relating to a transaction has this unique identifier. The DBMS writes a log
record for each of the following actions:
Start of a transaction
Read of a data item (not required in all recovery techniques)
Update of a data item
Insertion of a data item
Deletion of a data item
Search WWH ::




Custom Search