2) Explain how SHADOW PAGING is involved in the recovery mechanisms ?
PREREQUISITES
1) What is shadow paging? 2) What is the purpose of shadow paging? 3) Why we go for shadow paging? 4) Advantages over other recovery techniques 5) Demerits
SHADOW PAGING FIXED SIZE BLOCKS OR PAGES TABLES MAINTAINED DURING LIFETIME OF TRANSACTION SHADOW PAGE TABLE CURRENT PAGE TABLE STORED IN NON-VOLATILE STORAGE WHY SHADOW PAGING?
To provide 1) Atomicity - All (or) nothing principle 2) Durability - Updates must be saved in database permanently
How does shadow paging satisfies these two properties? Analysing the below conditions proves it 1) When a transaction begins execution 2) To recover from failure PICTORIAL REPRESENTATION TRANSACTION BEGINS Current page table Shadow page table Pointer to the disk block or a page Pages on disk WHEN UPDATES INVOLVED IN TRANSACTION? Current page table Shadow page table After update current page table entry updated to new disk block Shadow page table points to the unmodified disk block Pages on disk TRANSACTION COMMITS Current page table Shadow page table After update current page table entry updated to new disk block Shadow page table entry discarded Pages on disk WHEN TRANSACTION FAILS? Current page table Shadow page table Shadow page table points to the unmodified disk block Pages on disk Shadow page table is converted into Current page table TRANSACTION BEGINS EXECUTION WHAT HAPPENS? The current page table is copied into a shadow page table. Shadow page table is then saved shadow page table is never modified during transaction execution TRANSACTION FAILS - WHAT HAPPENS? Discard current page table The shadow page table to become the current page table Execution is available through the shadow page table LETS COMPARE ADVANTAGES Recovery is trivial No overhead of writing log records
DISADVANTAGES Data gets fragmented (related pages get separated on disk) After every transaction completion, the database pages containing old versions of modified data need to be garbage collected Commit overhead is high even with above extension Need to flush every updated page, and page table