written 6.4 years ago by | • modified 6.3 years ago |
• Shadow paging is a technique for providing atomicity and durability in database systems.
• Shadow paging is a copy-on-write technique for avoiding in-place updates of pages. Instead, when a page is to be modified, a shadow page is allocated.
• Since the shadow page has no references (from other pages on disk), it can be modified liberally, without concern for consistency constraints, etc. When the page is ready to become durable, all pages that referred to the original are updated to refer to the new replacement page instead. Because the page is "activated" only when it is ready, it is atomic.
• This increases performance significantly by avoiding many writes on hotspots high up in the referential hierarchy (e.g.: a file system superblock) at the cost of high commit latency.
Shadow paging considers:
The database is partitioned into fixed-length blocks referred to as PAGES.
Page table has n entries – one for each database page.
Each contain pointer to a page on disk (1 to 1st page on database and so on…).
The idea is to maintain 2 pages tables during the life of transaction.
The current page table
The shadow page table
When transaction starts, both page tables are identical
The shadow page table is never changed over the duration of the transaction.
The current page table may be changed when a transaction performs a write operation.
All input and output operations use the current page table to locate database pages on disk.
Advantages:
• No Overhead for writing log records.
• No Undo / No Redo algorithm.
• Recovery is faster.
Disadvantages:
• Data gets fragmented or scattered.
• After every transaction completion database pages containing old version of modified data need to be garbage collected.
• Hard to extend algorithm to allow transaction to run concurrently.