BCA / B.Tech 10 min read

Database Recovery

Database Recovery in DBMS:

Database Recovery is the process of restoring a database to its correct, consistent state after a failure. Failures can include system crashes, transaction errors, or disk failures. The recovery mechanism ensures the atomicity and durability properties of transactions.

Common Recovery Techniques:
  • Immediate Recovery (using Undo/Redo):
    • Rollback (Undo): Reverts the changes made by incomplete or failed transactions.
    • Rollforward (Redo): Re-applies the changes of committed transactions that were not permanently saved to disk before a crash.
  • Log-Based Recovery: This is the most common method. The DBMS maintains a log file that records all database modifications. After a failure, the log is used to undo or redo transactions to bring the database to a consistent state.
  • Checkpoint Recovery: To speed up recovery, the system periodically creates a checkpoint, which is a snapshot of the database state. After a crash, the recovery process only needs to consider transactions that occurred after the most recent checkpoint.
  • Media Recovery: This is used in case of a disk failure. The database is restored from the most recent backup, and then the transaction logs are used to roll forward and re-apply all subsequent committed transactions.