ADBMS Chapter 5. Database Recovery Technique - 2
ADBMS Chapter 5. Database Recovery Technique - 2
ADBMS Chapter 5. Database Recovery Technique - 2
To bring the database into the last consistent state, which existed prior to the
failure.
Example:
2 Types of Failure
For recovery from any type of failure data values prior to modification
(BFIM - BeFore Image) and the new value after modification (AFIM –
AFter Image) are required.
4 Data Update
copy is updated.
Shadow update: The modified version of a data item does not overwrite
In-place update: The disk version of the data item is overwritten by the
cache version.
Slide 5
Database Recovery
5 Data Caching
Slide 7
Database Recovery
Write-Ahead Logging
When in-place update (immediate or deferred) is used then log is necessary for
recovery and it must be available to recovery manager. This is achieved by
Write-Ahead Logging (WAL) protocol. WAL states that
For Undo: Before a data item’s AFIM is flushed to the database disk
(overwriting the BFIM) its BFIM must be written to the log and the log
must be saved on a stable store (log disk).
For Redo: Before a transaction executes its commit operation, all its
AFIMs must be written to the log and the log must be saved on a stable
store.
Slide 8
Database Recovery
7 Check pointing
Randomly or under some criteria, the database flushes its buffer to
database disk to minimize the task of recovery. The following steps
defines a checkpoint operation:
1. Suspend execution of transactions temporarily.
It avoids the need for a very large buffer space to store updated
pages in memory
Slide 10
4. No-Force: An updated page of a committed transaction may still be in
the buffer when another transaction needs to update it
This eliminate the I/O cost to read that page again from disk
Steal/No-Force (Undo/Redo)
Steal/Force (Undo/No-redo)
No-Steal/No-Force (Redo/No-undo)
No-Steal/Force (No-undo/No-redo)
Slide 11
Database Recovery
8 Recovery Scheme
Deferred Update (No Undo/Redo)
After reboot from a failure the log is used to redo all the transactions
affected by this failure. No undo is required because no AFIM is flushed
to the disk before a transaction commits.
Slide 12
Database Recovery
Deferred Update with concurrent users
During recovery, all transactions of the commit table are redone and all
transactions of active tables are ignored since none of their AFIMs
reached the database..
Slide 13
Database Recovery
Undo/No-redo Algorithm
In this algorithm AFIMs of a transaction are flushed to
the database disk under WAL before it commits.
No transaction is redone.
Slide 14
Database Recovery
Recovery Techniques Based on Immediate Update
Recovery schemes of this category apply undo and also redo for recovery.
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.
Slide 15
Database Recovery
Shadow Paging
This recovery scheme does not require the use of a log in a single user
environment. The AFIM does not overwrite its BFIM but recorded at another
place on the disk. Thus, at any time a data item has AFIM and BFIM
(Shadow copy of the data item) at two different places on the disk.
X Y
X' Y'
Database
Shadow Paging
An exmple of
shadow
paging
Slide 17
Database Recovery
Recovery in multi database system
A multi database system is a special distributed database system where one node
may be running relational database system under UNIX, another may be running
object-oriented system under Windows and so on.
In this execution scenario, the transaction commits only when all these multiple
nodes agree to commit individually the part of the transaction they were executing.
If any one of these nodes fails or cannot commit the part of the transaction,
then the transaction is aborted.
Each node recovers the transaction under its own recovery protocol. Slide 18
Recovery in multi database system(cont…)
To maintain the atomicity of multidatabase transaction(MDT) , it is
necessary to have a two level recovery mechanism.
A global recovery manager or coordinator is needed to maintain
information needed for recovery
The coordinator usually follows a Two-phase commit protocol which
can be explained as follows:
Phase1: when all participating databases signal the coordinator that the
part of the MDT involving each has concluded, the coordinator sends a
“prepare for commit” message to each participant to get ready for
committing the transaction
Each participating DB receiving that message will force write log
Phase 2:If all participating databases reply ok, the transaction is successful and
the coordinator sends a commit signal to the participating DBs
Because all the local effects of the transaction and information needed for
local recovery is recorded in the logs of participating DBs, recovery from
failure is now possible.
Consider the log records shown on the next slide by transactions T1, T2, T3
and T4 with initial values of B=15, C=50, D=40 and E=25. Using deferred
update, show the final values of B, C, D and E after recovery from failure if
the crash occurred after the indicated point
B C D E
15 50 40 25
Slide 21
Continued … Initial values
B C D E
[Start_transaction,T1] 15 50 40 25
[write_item,T1,B,12]
[write_item,T1,D,10]
[commit T1]
[checkpoint]
Final values after recovery
[Start_transaction,T3]
[write_item,T3,E,30] B C D E
[commit T3] ? ? ? ?
[Start_transaction,T4]
[write_item,T4,B,18]
[commit T4]
[Start_transaction,T2]
[write_item,T2,C,28]
Crash Slide 22
Thank you!
Slide 23