2082 7

BIT202 ยท 2082 ยท 5 marks

What is database recovery? How can shadow paging be used for database recovery?

What is database recovery? How can shadow paging be used for database recovery? [5]

Database Management SystemChapter 9: Database Recovery and ReliabilityDatabase recovery definition

Quick answer

Database recovery is the process of restoring a database to a correct and consistent state after a failure (such as system crash, transaction failure, media failure, or power loss).

Database Recovery and Shadow Paging

What is Database Recovery? (2 marks)

The primary goals of database recovery are:

  • Atomicity: Ensure that incomplete transactions are rolled back (undone).
  • Durability: Ensure that committed transactions are not lost.

Recovery relies on the concept of maintaining redundant information (logs, shadow copies) so that the database can be restored to the last consistent state.


Shadow Paging for Database Recovery (3 marks)

Shadow paging is a recovery technique that avoids the use of a log file by maintaining two page tables simultaneously:

Page TableDescription
Current Page TablePoints to the most recent (active) pages being modified by the current transaction.
Shadow Page TablePoints to the last committed consistent state of the database (never modified during the transaction).

How Shadow Paging Works

Setup:

  • The database is organized into fixed-size pages.
  • At the start of a transaction, both the current page table and the shadow page table point to the same physical pages on disk.

During a Transaction:

  • When a transaction modifies a page, a new copy of that page is created in a different disk location.
  • The current page table is updated to point to the new (modified) page.
  • The shadow page table remains unchanged, still pointing to the old (original) pages.
Shadow Page Table          Current Page Table
  [Page 1] --> P1            [Page 1] --> P1  (unchanged)
  [Page 2] --> P2            [Page 2] --> P2' (new modified copy)
  [Page 3] --> P3            [Page 3] --> P3  (unchanged)

On COMMIT (Transaction Success):

  1. All modified pages are written to disk.
  2. The current page table replaces the shadow page table (i.e., the shadow page table pointer is updated to point to the current page table).
  3. The old shadow pages that were replaced are freed.
  4. The database is now in a new consistent state.

On ABORT / Failure (Transaction Failure):

  1. The current page table is simply discarded.
  2. The shadow page table (which still points to the old consistent pages) is restored as the current page table.
  3. No undo operations are needed -- the database automatically reverts to the last consistent state.

Advantages of Shadow Paging

  • No need for a redo/undo log.
  • Recovery is simple and fast -- just restore the shadow page table.
  • No cascading rollbacks.

Disadvantages of Shadow Paging

  • Fragmentation: Pages of the same file may scatter across disk over time.
  • Garbage collection: Old shadow pages must be reclaimed.
  • Overhead: Copying entire pages even for small changes is costly.
  • Not suitable for large databases with many concurrent transactions.

Summary: Shadow paging ensures recovery by keeping an untouched shadow copy of the last consistent database state. On failure, the shadow copy is restored; on commit, the shadow is updated to reflect the new state.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.