Published on July 12, 2014
Database recovery techniques: Database recovery techniques Introduction: Introduction Database recovery is the process of restoring the database to the most recent consistent state that existed just before the failure. Three states of database recovery: Pre-condition : At any given point in time the database is in a consistent state. Condition : Occurs some kind of system failure. Post-condition: Restore the database to the consistent state that existed before the failure Types of failures: Types of failures Transaction failures. Erroneous parameter values Logical programming errors System errors like integer overflow, division by zero Local errors like “data not found” User interruption. Concurrency control enforcement Malicious transactions. System crash. A hardware, software, or network error (also called media failure) Disk crash. Before step into recovery.: Before step into recovery. Commit point: Every transaction has a commit point. This is the point at which it is finished, and all of the database modifications are made a permanent part of the database. Recovery approaches: Recovery approaches Steal approach -cache page updated by a transaction can be written to disk before the transaction commits. No-steal approach -cache page updated by a transaction cannot be written to disk before the transaction commits. Force approach - when a transaction commits, all pages updated by the transaction are immediately written to disk. No-force approach -when a transaction commits, all pages updated by the transaction are not immediately written to disk. Basic Update Strategies: Basic Update Strategies Update strategies may be placed into two basic categories. Most practical strategies are a combination of these two: Basic Update Strategies Deferred Update Immediate Update Cont.: Cont. Deferred Update (No -Undo/Redo Algorithm) These techniques do not physically update the DB on disk until a transaction reaches its commit point. These techniques need only to redo the committed transaction and no-undo is needed in case of failure. This technique support abort and machine failure scenarios. Cont.: Cont. While a transaction runs: Changes made by that transaction are not recorded in the database. On a commit: The new data is recorded in a log file and flushed to disk The new data is then recorded in the database itself. On an abort, do nothing (the database has not been changed). On a system restart after a failure, REDO the log. Cont.: Cont. Immediate Update (Undo/Redo Algorithm) The DB may be updated by some operations of a transaction before the transaction reaches it’s commit point. The updates are recorded in the log must contain the old values and new values. These techniques need to undo the operations of the uncommitted transactions and redo the operations of the committed transactions . Cont.: Cont. While a transaction runs: Changes made by the transaction can be written to the database at any time. Both original and the new data being written, must be stored in the log before storing it on the disk. On a commit: All the updates which has not yet been recorded on the disk is first stored in the log file and then flushed to disk. The new data is then recorded in the database itself. On an abort, redo all the changes which that transaction has made to the database disk using the log entries. On a system restart after a failure, redo committed changes from log. Shadow Paging: When a transaction begins executing the current page table is copied into a shadow page table. shadow page table is then saved shadow page table is never modified during transaction execution Shadow Paging In this technique, the database is considered to be made up of fixed-size disk blocks or pages for recovery purposes. Maintains two tables during the lifetime of a transaction-current page table and shadow page table. Store the shadow page table in nonvolatile storage, to recover the state of the database prior to transaction execution This is a technique for providing atomicity and durability. Cont.: To recover from a failure discard current page table the shadow page table to become the current page table execution is available through the shadow page table Cont. Advantages No-redo/no-undo Disadvantages Creating shadow directory may take a long time. Updated database pages change locations. Garbage collection is needed “ARIES” Recovery algorithm.: “ARIES” Recovery algorithm. Recovery algorithms are techniques to ensure database consistency ,transaction atomicity and durability without any failure. Recovery algorithms have two parts Actions taken during normal transaction processing to ensure enough information exists to recover from failures. Actions taken after a failure to recover the database contents to a state that ensures atomicity, consistency and durability. Cont.: Cont. ARIES ( A lgorithms for R ecovery and I solation E xploiting S emantics) The ARIES recovery algorithm consist of three steps Analysis Redo Undo Cont.: Cont. Analysis - Identify the dirty pages(updated pages) in the buffer and set of active transactions at the time of failure. Redo - Re-apply updates from the log to the database. It will be done for the committed transactions. Undo - Scan the log backward and undo the actions of the active transactions in the reverse order. Recovery from disk crashes.: Recovery from disk crashes. Recovery from disk crashes is much more difficult than recovery from transaction failures or machines crashes. Loss from such crashes is much less common today than it was previously, because of the wide use of redundancy in secondary storage (RAID technology). (RAID - method of combining several hard disk drives into one logical unit.) Typical methods are; The log for the database system is usually written on a separate physical disk from the database. or, Periodically, the database is also backed up to tape or other archival storage. Conclusion.: Conclusion. Types of failures. Steal/no steal, Force/no force approaches. Deferred and immediate update strategies. Shadow paging technique. ARIES recovery algorithm. Recovery from disk crashes. Thank you !: Thank you !