BCA / B.Tech 5 min read

The Need for Recovery

The Need for Recovery in RDBMS:

Recovery is the process of restoring a database to a consistent state after a failure. Failures are inevitable in any system due to hardware issues, software bugs, or power outages. Without a proper recovery mechanism, a failure could lead to data loss or leave the database in an inconsistent state, violating its integrity. The primary need for recovery is to ensure the Durability and Atomicity properties of transactions.

Common Recovery Techniques:
  • Log-Based Recovery: The most common technique. All database modifications are written to a log file before being applied to the database itself. After a crash, the log is used to either undo incomplete transactions or redo committed transactions that weren't saved to disk.
  • Checkpointing: To reduce recovery time, the system periodically saves the current state of the database to disk and writes a checkpoint record to the log. After a crash, the recovery process only needs to consider transactions that occurred after the last checkpoint.
  • Shadow Paging: This technique maintains two page tables during the life of a transaction: a current page table and a shadow page table. Updates are made to a copy of the database pages, and when the transaction commits, the current page table is updated to point to the modified pages.