DBMS31052024
DBMS31052024
<T1 commit>
C = 600
BA
• example transactions
T1 : read (C)
C:- C- 100
write (C)
NPTEL Question:
Q. Consider the following example of a log of two transactions, where
deferred database modification scheme is used. [CRPQ-5]
Steps Details of log If a crash occurs just after step 6 and the recovery of
1 <T0 start> the system is successfully completed, which of the
2 <T0, A, 950> following action is true?
3 <T0, B, 2050> (a) T0: redo and T1: redo
4 <T1 start>
(b) T0: redo and T1: undo
5 <T1, C, 200>
(c) T0: redo and T1: No action
6 <T1 commit>
(d) T0: No action and T1: redo
NPTEL Question:
Q. Consider the following example of a log of two transactions, where
deferred database modification scheme is used. [CRPQ-7]
Steps Details of log If a crash occurs just after step 7 and the recovery of
1 <T0 start> the system is successfully completed, which of the
2 <T0, A, 500>
following action is true?
3 <T0, B, 1000>
(a) T0: redo and T1: redo
4 <T1 start>
(b) T0: redo and T1: undo
5 <T1, C, 200>
6 <T0 commit> (c) T0: redo and T1: No action
7 <T1 commit> (d) T0: No action and T1: No action
Check Points
• Problems in recovery procedure are,
1. searching the entire log is time-consuming
2. we might unnecessarily redo transactions which have already
output their updates to the database.
• Streamline recovery procedure by periodically performing
checkpointing
1. Output all log records currently residing in main memory onto
stable storage.
2. Output all modified buffer blocks to the disk.
3. Write a log record < checkpoint L> onto stable storage.
When the system recovers from a crash, it first does the following:
1. Initialize undo-list and redo-list to empty
2. Scan the log backwards from the end, stopping when the first
<checkpoint L> record is found.
For each record found during the backward scan:
if the record is <Ti commit>, add Ti to redo-list
if the record is <Ti start>, then if Ti is not in redo-list, add Ti to
undo- list
3. For every Ti in L, if Ti is not in redo-list, add Ti to undo-list
At this point undo-list consists of incomplete transactions which
must be undone, and redo-list consists of finished transactions
that must be redone.
Recovery now continues as follows:
1. Scan log backwards from most recent record, stopping when
<Ti start> records have been encountered for every Ti in undo-
list.
During the scan, perform undo for each log record that
belongs to a transaction in undo-list.
2. Locate the most recent <checkpoint L> record.
3. Scan log forwards from the <checkpoint L> record till the
end of the log.
During the scan, perform redo for each log record that
belongs to a transaction on redo-list
Example of Check points
Tc Tf
T1
T2
T3
T4