Page 193 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 193
Database Management Systems/Managing Database
Notes 1. Log record notes that T has performed a write on data item X. X had value V before the
i 1
write, and will have value V after the write.
2
2. When T finishes it last statement, the log record <T commit> is written. We assume for
i i
now that log records are written directly to a stable storage media (that is, they are not
buffered).
Two approaches for recovery using logs are:
1. Deferred database modification.
2. Immediate database modification.
Deferred Database Modification
The deferred database modification scheme records all the modifications to the log, but defers
all the writes to after partial commit. Let us assume that transactions execute serially, to simplify
the discussion.
A transaction starts by writing <T start> record to log. A write(X) operation results in a log
i
record <T , X, V > being written, where V is the new value for X. The write is not performed on
i
X at this time, but is deferred. When T partially commits, <T commit> is written to the log.
i i
Finally, the log records are read and used to actually execute the previously deferred writes.
During recovery after a crash, a transaction needs to be redone if both <T start> and<T commit>
i i
are there in the log. Redoing a transaction T (redoT ) sets the value of all data items updated by
i i
the transaction to the new values. Crashes can occur while
1. The transaction is executing the original updates, or
2. While recovery action is being taken.
Example: Transactions T and T (T executes before T ):
1 2 1 2
T : read (X) T : read (Z)
1 2
X= X”1000 Z= Z” 1000
Write (X) write (Z)
read (Y)
Y= Y + 1000
write (Y)
The following figure shows the log as it appears at three instances of time (Assuming that initial
balance in X is 10,000/- Y is 8,000/- and Z has 20,000/-):
Figure 11.1
<T start> <T start> <T start>
1 1 1
<T , X 9000> <T , X 9000> <T , X 9000>
1 1 1
<T , Y 9000> <T , Y 9000> <T , Y 9000>
1 1 1
<T , Commit> <T , Commit>
1 1
<T start> <T start>
2 2
<T , Z 19000> <T , Z 19000>
2 2
<T , Commit>
2
(a) (b) (c)
186 LOVELY PROFESSIONAL UNIVERSITY