Database Recovery


Database recovery means recovering the data when it gets deleted, hacked, or damaged accidentally. Atomicity is a must whether is transaction is over or not it should reflect in the database permanently or it should not affect the database at all.

Here are some reasons for database failure:-
  1. Transaction Failure-  It is basically due to Logical errors and System errors.  
  2. System Crash-  These are issues that will cause the system to prevent abruptly and cause the system to crash. It can be due to interruption in electricity or software failure.
  3. Disk Failure-  Disk failures include the formation of dangerous sectors, unreachability to the disk, disk crash, or the other failure, that destroys all or a section of disk storage.

Recovery Techniques

When a system crashes, it should have many transactions being executed and numerous files open for them to switch the information items. Transactions are a product of numerous operations that are atomic in nature.

Here are some forms of techniques, which may facilitate a database management system in recovering as well as maintaining the atomicity of a transaction:

  1. Maintaining the logs of every transaction
  2. Redo and Undo phase

Log-based recovery- The log is a sequence of records, which maintains the records of actions performed by dealing. The log file is unbroken on a stable storage media. When a transaction enters the system and starts execution, it writes a log regarding it. It has these fields:

• Transaction identifier is the unique identifier of the transaction that performed the write operation.
• Data-item identifier is the unique identifier of the data item written. Typically, it is the location on disk of the data item.
• Old value is the value of the data item prior to the write.
• New value is the value that the data item will have after the write.

Redo and Undo phase-

In the redo phase, the system replays updates of all transactions by scanning the log forward from the last checkpoint. The log records that are replayed include log records for transactions that were rolled back before the system crash and those that had not committed when the system crash occurred.

In the undo phase, the system rolls back all transactions in the undo-list. It performs rollback by scanning the log backward from the end. Whenever it finds a log record belonging to a transaction in the undo-list, it performs undo actions just as if the log record had been found during the rollback of a failed transaction.

Post a Comment

0 Comments