This technique ensures that a database can recover seamlessly from failures without
losing data integrity. During a transaction, updates are made to a new version of the
database pages tracked by the current page table, while the shadow page table preserves
the pre-transaction state. This dual-table approach allows for efficient crash recovery and
simplifies the commit and rollback processes.
Page Table : A page table is a data structure that maps logical pages (a logical division of
data) to physical pages (actual storage on disk).
Each entry in the page table corresponds to a physical page location on the disk.
The database uses the page table to retrieve or modify data.
How Shadow Paging Works ?
Shadow paging is a recovery technique that views the database as a collection of fixed-
sized logical storage units, known as pages, which are mapped to physical storage blocks
using a structure called the page table. The page table enables the system to efficiently
locate and manage database pages.
Here’s how shadow paging works in detail:
Start of Transaction:
The shadow page table is created by copying the current page table.
The shadow page table represents the original, unmodified state of the database.
This table is saved to disk and remains unchanged throughout the transaction.
Logical Page Shadow Page Table (Disk) Current Page Table
P1 Address_1 Address_1
P2 Address_2 Address_2
P3 Address_3 Address_3
Transaction Execution:
Updates are made to the database by creating new pages.
The current page table reflects these changes, while the shadow page table remains
unchanged.
Page Modification:
If a logical page (e.g. P2) needs to be updated:
A new version of the page (P2’) is created in memory and written to a new physical
storage block.
The current page table entry for P2 is updated to point to P2’.
The shadow page table still points to the original page P2, ensuring it is unaffected by
the changes.
Logical Page Shadow Page Table (Disk) Current Page Table
P1 Address_1 Address_1
P2 Address_2 Address_4 (P2′)
P3 Address_3 Address_3
Commit:
If the transaction is successful, the shadow page table is replaced by the current page
table.
This replacement makes the changes permanent.
Logical Page Shadow Page Table (Disk) Current Page Table
P1 Address_1 Address_1
P2 Address_4 (P2′) Address_4 (P2′)
P3 Address_3 Address_3
Abort:
If the transaction is aborted, the current page table is discarded, leaving the shadow
page table intact.
Since the shadow page table still points to the original pages, no changes are reflected
in the database.