0 9

BIT202 ยท 0 ยท 5 marks

What is shadow paging? How it is used for database recovery?

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

Database Management SystemChapter 9: Database Recovery and ReliabilityShadow paging technique

Quick answer

Shadow paging is a recovery technique used in database management systems that maintains two page tables simultaneously: Current Page Table - reflects all changes made by the current (active) transaction; Shadow Page Table - a copy of the page table taken at the start of the transaction; it remains unchanged during...

Shadow Paging

Definition

Shadow paging is a recovery technique used in database management systems that maintains two page tables simultaneously:

  • Current Page Table - reflects all changes made by the current (active) transaction.
  • Shadow Page Table - a copy of the page table taken at the start of the transaction; it remains unchanged during the transaction and points to the last consistent state of the database.

The shadow page table is stored on disk (non-volatile storage), ensuring it survives system crashes.


How Shadow Paging Works

Setup

When a transaction begins:

  1. A shadow page table is created as an exact copy of the current page table.
  2. Both tables initially point to the same physical disk pages.

During Transaction Execution

When a transaction wants to modify a page:

  1. A new copy of that page is created on disk (copy-on-write).
  2. The current page table is updated to point to the new (modified) page.
  3. The shadow page table continues to point to the original (old) page.
Shadow Page Table          Current Page Table
  Page 1 --> Block A         Page 1 --> Block A  (unchanged)
  Page 2 --> Block B         Page 2 --> Block B' (modified copy)
  Page 3 --> Block C         Page 3 --> Block C  (unchanged)

Recovery Using Shadow Paging

On Commit (Successful Transaction)

  1. All modified pages in the current page table are written to disk.
  2. The current page table replaces the shadow page table (shadow is discarded).
  3. The old pages (pointed to by the shadow) are freed/reclaimed.
  4. The database is now in the new consistent state.

On Abort / System Crash (Unsuccessful Transaction)

  1. The current page table is simply discarded.
  2. The shadow page table is restored as the current page table.
  3. All newly written (modified) pages are discarded.
  4. The database automatically returns to the last consistent state -- no undo/redo logs are needed.

Advantages of Shadow Paging

FeatureBenefit
No redo logs neededCommitted data is already on disk
No undo logs neededRecovery is done by restoring shadow table
Simple recoveryJust switch back to shadow page table
No cascading rollbackEach transaction is isolated

Disadvantages of Shadow Paging

  • Fragmentation: Modified pages are scattered across disk (no locality).
  • Garbage collection: Old shadow pages must be reclaimed after commit.
  • Overhead: Copying the entire page table at transaction start is costly for large databases.
  • Not suitable for concurrent transactions: Managing multiple shadow tables is complex.

Summary

Shadow paging provides atomicity and durability without using a traditional log. By keeping an unchanged shadow copy of the page table, the system can recover from failures by simply reverting to the shadow, making it a straightforward but limited recovery mechanism suitable for single-user or small database systems.

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