ADBMS Chapter 4
ADBMS Chapter 4
G2CS&IT
Database Recovery Techniques
DBMS is highly complex system with hundreds of transactions being executed every second.
Availability of DBMS depends on its complex architecture and underlying hardware or system
software. If it fails or crashes amid transactions being executed, it is expected that the system
would follow some sort of algorithm or techniques to recover from crashes or failures.
Recovery from transaction failures means that the database is restored to the most recent
consistent state just before the failure. It is a service provided by the DBMS to ensure that the
database is reliable and remains in a consistent state in the presence of failure.
Failure Classification
- System crash: hardware, software, network error occurs during transaction execution.
- Transaction error: some operation [e.g. Div by 0, overflow] in the transaction may cause
it to fail)
- Exception conditions, detected by the transaction: Data not found.
- Concurrency control enforcement: serializability, deadlock.
- Disk failure (read/write phase), physical problems (theft).
Shadow Paging
A recovery scheme
In a single-user environment, doesn’t require the use of log.
In multi-user environment, the log may be needed for concurrency control method.
- The DB is made up of ‘n’ fixed-size disk pages –blocks.
- A directory with ‘n’ entries where the ith entry points to the ith DB page on disk.
o All references –reads or writes- to the DB pages on disk go through the directory.
o The directory is kept in main memory if not too large.
o The current directory entries point to the most recent or current DB pages on disk.
- When a transaction begins executing, the current directory is copied into a shadow directory
and the shadow directory is saved on disk.
- During transaction execution, all updates are performed using the current directory and the
shadow directory is never modified.
Prepared by : Mrs.Pravicha.M.T Page 7
Chapter 4: Advanced Database Management
G2CS&IT
- When a write_item operation is performed
o A new copy of the modified DB page is created and the old copy is not overwritten. Two
versions, of the page updated by the transaction, are kept.
o The new page is written elsewhere
on some unused disk block.
o The current directory entry is
modified to point to the new disk
block.
o The shadow directory is not
modified.
- To recover from a failure:
o Delete the modified database
pages & discard the current
directory.
o The state of the database before
transaction execution is available through the shadow directory and is recovered by
reinstating the shadow directory.
o Committing a transaction corresponds to discarding the previous shadow directory.
o NO-UNDO/NO-REDO technique since neither undoing or redoing of data items
In a multiuser environment, logs and checkpoints must be incorporated.
Drawbacks
- The updated pages change location on disk.
- Difficult to keep related DB pages close together on disk without complex storage
management strategies.
- The overhead of writing shadow directories to disk as transactions start is significant.
- A complicated garbage collection when a transaction commits.
- The old pages referenced by the shadow directory that have been updated must be released
and added to a list of free pages for future use.
- The migration between current and shadow directories must be implemented as an atomic
operation
ARIES ALGORITHM - An Example of a recovery algorithm used in database systems.
REDO Phase
ARIES starts redoing at a point in the log where it knows (for sure) that previous changes to dirty
pages have already been applied to the database on disk.
Suppose the smallest LSN of all the dirty pages in the Dirty Page Table is M.
REDO starts at the log record with LSN = M and scans forward to the end of the log.
For any changes corresponding to an LSN < M, transactions, must have already been
propagated to disk or already been overwritten in the buffer; otherwise, those dirty pages
with that LSN would be in the buffer (and the Dirty Page Table).
For each change recorded in the log, the REDO algorithm would verify whether or not the
change has to be reapplied.
If a change recorded in the log pertains to page P that is not in the Dirty Page Table, then
this change is already on disk and does not need to be reapplied.
If a change recorded in the log (with LSN = N, say) pertains to page P and the Dirty Page
Table contains an entry for P with LSN greater than N, then the change is already present.
If neither of these two conditions hold, page P is read from disk and the LSN stored on
that page, LSN(P), is compared with N. If N < LSN(P), then the change has been applied
and the page does not need to be rewritten to disk.
UNDO Phase
The set of active transactions called the undo_set has been identified in the Transaction
Table during the analysis phase.
Consider the recovery example shown in Figure 23.5. There are three transactions:
T1, T2, and T3. T1 updates page C, T2 updates pages B and C, and T3 updates page A.
Review Questions
1. Discuss the different types of transaction failures. What is meant by catastrophic failure?
2. What is the system log used for? What are the typical kinds of entries in a system log?
What are checkpoints, and why are they important? What are transaction commit points,
and why are they important?
3. How are buffering and caching techniques used by the recovery subsystem?
4. Describe the write-ahead logging protocol.
5. What is the difference between the UNDO/REDO and the UNDO/NO-REDO algorithms
for recovery with immediate update?
6. Describe the shadow paging recovery technique. Under what circumstances does it not
require a log?
7. What are log sequence numbers (LSNs) in ARIES? How are they used? What
information do the Dirty Page Table and Transaction Table contain?
8. Describe how fuzzy checkpointing is used in ARIES.
9. Describe the three phases of the ARIES recovery method.
10. What do the terms steal/no-steal and force/no-force mean with regard to buffer
management for transaction processing?