Professional Documents
Culture Documents
[DBMS]
Database Recovery
Techniques
Chapter 11
UNIT V
By C.Aruna Devi(DSCASC) 1
Database Recovery
Purpose of Database Recovery:
By C.Aruna Devi(DSCASC) 2
Database Recovery
Types of Failure:
By C.Aruna Devi(DSCASC) 4
Recovery Techniques
By C.Aruna Devi(DSCASC) 5
Recovery Techniques
Recovery Techniques Based on Deferred Update:
After the transaction reaches its commit point and the log is
force written to disk, the updates are recorded in the
database.
By C.Aruna Devi(DSCASC) 6
Recovery Techniques Based on Deferred Update
A transaction does not reach its commit point until all its update
operations are recorded in the log and the log is forced written to disk.
By C.Aruna Devi(DSCASC) 7
Deferred Update in a single-user system
Deferred Update in a single-user system:
After the transaction reaches its commit point and the log is
force written to disk, the updates are recorded in the database.
After reboot from a failure the log is used to redo all the
transactions affected by this failure.
By C.Aruna Devi(DSCASC) 8
Deferred Update in a single-user system
(a) T1 T2
read_item (A) read_item (B)
read_item (D) write_item (B)
write_item (D) read_item (D)
write_item (D)
(b)
[start_transaction, T1]
[write_item, T1, D, 20]
[commit T1]
[start_transaction, T2]
[write_item, T2, B, 10]
[write_item, T2, D, 25] ← system crash
By C.Aruna Devi(DSCASC) 10
Deferred Update with concurrent users
T1
T2
T3
T4
T5
t1 Time t2
checkpoint system crash
Recovery in a concurrent users environment.
Example:
•When the checkpoint was taken at time t1, transaction T1 had committed, where as transactions T3 & T4
had not.
• Before the system crash at time t2, T3 & T2 were committed but not T4 & T5.
• According to RDU_M method, there is no need to redo the write_item operations of transaction T1.
• Write_item operation of T2 & T3 must be redone because both transaction reached their commit point after
the last check point.
• Recall that the log is force-written before committing a transaction.
• Transaction T4 & T5 are ignored.
• They are effectively canceled or rolled back because none of their write_item operations were recorded in
the database.
By C.Aruna Devi(DSCASC) 11
Deferred Update with concurrent users
(a) T1 T2 T3 T4
read_item (A) read_item (B) read_item (A) read_item (B)
read_item (D) write_item (B) write_item (A) write_item (B)
write_item (D) read_item (D) read_item (C) read_item (A)
write_item (D) write_item (C) write_item (A)
T2 and T3 are ignored because they did not reach their commit points.
T4 is redone because its commit point is after the last checkpoint.
By C.Aruna Devi(DSCASC) 12
Deferred Update with concurrent users
Two tables are required for implementing this protocol:
During recovery, all transactions of the commit table are redone and
all transactions of active tables are ignored since none of them
reached the database.
This technique, when a transaction issues an update command, the database can
be updated “immediately” without any need to wait for the transaction to reach
its commit point.
However an update operation must still be recorded in the log before it applied to
the database.
Provision must be made for undoing the effect of update operations that have
been applied to the database by a failed transaction.
This is accomplished by rolling back the transaction and undoing the effect of the
transaction write_item operations.
If the recovery technique ensures that all updates of a transaction are recorded in
the database on disk before the transaction commits, there is never a need to
REDO any operation of committed transactions.
By C.Aruna Devi(DSCASC) 14
Recovery Techniques Based on Immediate Update
Undo/Redo Algorithm (Single-user environment):
Recovery schemes of this category apply undo and also redo for
recovery.
In a single-user environment no concurrency control is required
but a log is maintained.
Note that at any time there will be one transaction in the system
and it will be either in the commit table or in the active table.
By C.Aruna Devi(DSCASC) 15
Recovery Techniques Based on Immediate Update
Undo/Redo Algorithm (Concurrent execution):
By C.Aruna Devi(DSCASC) 16