Skip to content
Contents/CH 24
Transactions & Recovery/Advanced · 12 min

Recovery: Shadow Paging

Shadow paging avoids a log by never overwriting the live page table. It switches pointers atomically and keeps the old version as a shadow.

In plain English

Write the new version on a fresh page, then switch the bookmark.

The one idea

Shadow paging writes changed pages to new locations and atomically switches the page-table root, so the old state survives a crash.

It is an elegant alternative to undo logging: if the switch did not happen, the old database is still intact.

By the end

  1. 01Explain current and shadow page tables.
  2. 02Describe the atomic commit switch.
  3. 03Know the cost of garbage collection.
  4. 04Compare shadow paging with logging.
01

Current and shadow pages

The database keeps a current page table and a shadow page table. Updates are written to new pages, not the live pages. The current table points to the new pages; the shadow table still points to the old consistent state.

02

Atomic commit

At commit, the DBMS writes the updated page table to disk and atomically switches the root pointer to it. Before the switch, the shadow table is the consistent state; after the switch, the new table is. A crash during the switch leaves either the old or the new state, never a mixture.

chapter-24.db
before commit:
shadow -> old pages (consistent)
current -> new pages (uncommitted)

commit:
write current page table
atomic switch root -> current
03

Costs and comparison

Shadow paging avoids undo/redo logging for page writes, but it fragments the disk because updated pages are written elsewhere. It also needs garbage collection for old pages and can be expensive for large transactions. Logging is more common in modern systems because it handles large updates and recovery more flexibly.

Worked example3 steps

Switch the page table, not the page

The current page table points page 3 to disk block 30. A transaction updates page 3.

01

Copy page 3 to a new block, 41, and modify the copy.

The old block 30 remains untouched.

02

Force the new page and a new page table to disk.

The old root still points to block 30; the new root points to block 41.

03

Atomically update the root pointer.

A crash before the switch leaves the old state; after the switch, the new state is durable.

ConclusionShadow paging replaces undo with copy-on-write and a pointer swap. It avoids undo logs, but it fragments pages and complicates reclamation.

The trade-off

No free correctness.

Gain

No undo log and a simple crash-recovery story.

Cost

Copy-on-write overhead, page-table growth, and garbage collection of old pages.

Verdict

Conceptually important and used in some systems, but most large databases prefer WAL.

Recap

What to keep.

Takeaways

  • +Shadow paging writes updates to new pages.
  • +The shadow page table preserves the last consistent state.
  • +Commit switches the root pointer atomically.
  • +Old pages require garbage collection.
  • +Logging is generally more flexible for large transactions.

Traps

  • !Thinking shadow paging never writes to disk.
  • !Forgetting that old pages consume space until collected.
  • !Assuming the atomic switch is free.

Focus

  • →Explain the current and shadow tables.
  • →Trace a commit and a crash before/after the switch.
  • →Compare shadow paging with WAL.

Check yourself

Before you turn the page.

0 / 2 answered
01

What does the shadow page table represent?

02

What is a cost of shadow paging?

DB//COSMOS

A field manual for database systems: model the domain, normalize the facts, query the relations, and protect the result.

Edition 2026 · 32 chaptersTopic catalogInterview prep