Database management systems turn to a number of recovery management methods in order to recover from database failure. We will review the various approaches to database recovery in this chapter.
Typical database recovery methods are −
Power loss causes information in the non-persistent memory to be lost. The operating system and the database management system restart when power is restored. The Recovery Manager initiates the transaction log recovery.
The recovery manager takes the following steps in the event of an immediate update mode-
The recovery manager takes the following steps in the case of a deferred update mode-
A complete database loss is caused by a disk failure or hard crash. A new disk is prepared to recover from this hard crash, then the operating system is restored and eventually the database is recovered using the backup and transaction log of the database. For both immediate and delayed update modes, the recovery technique is the same.
The recovery manager takes the acts that follow-
Checkpoint is the time that a record is written from the buffers into the database. As a result, the recovery manager would not have to redo the transactions that were committed prior to the checkpoint in the event of a system crash. Periodic checkpointing shortens the process of recovery.
The two types of techniques for checkpointing are-
Consistent checkpointing produces at the checkpoint a consistent picture of the database. Only those transactions which are on the right side of the last checkpoint are undone or redone during recovery. Transactions are already committed on the left side of the last consistent checkpoint and do not need to be processed again. The checkpointing steps taken are −
If the transaction log is also archived in step 4, this checkpoint helps to recover from disk failures and power failures, otherwise it helps to recover from power failures only.
In fuzzy checkpointing, all successful transactions are written into the log at the time of the checkpoint. The recovery manager processes only those transactions that were active during the checkpoint and later in the event of a power failure. The transactions that have been committed before checkpoint are written to the disk and therefore need not be redone.
Example of Checkpointing
Let us consider that tcheck is the time of checkpointing in the system and tfail is the time of system crash. Let there be four transactions Ta, Tb, Tc and Td such that −
The situation is depicted in the following diagram −
The actions that are taken by the recovery manager are −
Recovery of transactions is performed to remove the adverse effects of faulty transactions rather than to recover from a failure. Faulty transactions involve all transactions that have modified the database to an undesired state, and all transactions that have used faulty transaction-written values.
In these cases, transaction recovery is a two-step process-
Steps for the UNDO operation are −
Steps for the REDO operation are −