Shadow Paging Technique
Concept of Shadow Paging Technique
- Shadow paging is an alternative to transaction-log based recovery techniques.
- Here, the database considered as made up of fixed size disk blocks, called pages. These pages mapped to physical storage using a table, called page table.
- The page table indexed by a page number of the database. The information about physical pages, in which database pages are stored, is kept in this page table.
- This technique is similar to paging technique used by Operating Systems to allocate memory, particularly to manage virtual memory.
- The following figure depicts the concept of shadow paging.
Execution of Transaction
- During the execution of the transaction, two-page tables maintained.
- Current Page Table: Used to access data items during transaction execution.
- Shadow Page Table: Original page table, and not get modified during transaction execution.
- Whenever any page is about to written for the first time
- A copy of this page made into a free page,
- The current page table made to point to the copy,
- The update made in this copy.
- At the start of the transaction, both tables same and point· to same pages.
- The shadow page table never changed and used to restore the database in case of any failure occurs. However, current page table entries may change during transaction execution, as it used to record all updates made to the database.
- When the transaction completes, the current page table becomes shadow page table. At this time, it considered that the transaction has committed.
- The following figure explains working on this technique.
- As shown in this figure, two pages – page 2 & 5 – affected by a transaction and copied to new physical pages. The current page table points to these pages.
- The shadow page table continues to point to old pages which are not changed by the transaction. So, this table and pages used for undoing the transaction.
Advantages of Shadow Paging Technique
- No overhead of maintaining the transaction log.
- Recovery is quite faster, as there is no any redo or undo operations required.
- Copying the entire· page table is very expensive.
- Data scattered or fragmented.
- After each transaction, free pages need to collect by the garbage collector.
- Difficult to extend this technique to allow concurrent transactions.