Introduction of Shadow Paging

Shadow Paging is recovery technique that is used to recover database. In this recovery technique, database is considered as made up of fixed size of logical units of storage which are referred as pages. pages are mapped into physical blocks of storage, with help of the page table which allow one entry for each logical page of database. This method uses two page tables named current page table and shadow page table.

The entries which are present in current page table are used to point to most recent database pages on disk. Another table i.e., Shadow page table is used when the transaction starts which is copying current page table. After this, shadow page table gets saved on disk and current page table is going to be used for transaction. Entries present in current page table may be changed during execution but in shadow page table it never get changed. After transaction, both tables become identical.

This technique is also known as Cut-of-Place updating.




To understand concept, consider above figure. In this 2 write operations are performed on page 3 and 5. Before start of write operation on page 3, current page table points to old page 3. When write operation starts following steps are performed :

  1. Firstly, search start for available free block in disk blocks.
  2. After finding free block, it copies page 3 to free block which is represented by Page 3 (New).
  3. Now current page table points to Page 3 (New) on disk but shadow page table points to old page 3 because it is not modified.
  4. The changes are now propagated to Page 3 (New) which is pointed by current page table.

COMMIT Operation :
To commit transaction following steps should be done :

  1. All the modifications which are done by transaction which are present in buffers are transferred to physical database.
  2. Output current page table to disk.
  3. Disk address of current page table output to fixed location which is in stable storage containing address of shadow page table. This operation overwrites address of old shadow page table. With this current page table becomes same as shadow page table and transaction is committed.

Failure :
If system crashes during execution of transaction but before commit operation, With this, it is sufficient only to free modified database pages and discard current page table. Before execution of transaction, state of database get recovered by reinstalling shadow page table.

If the crash of system occur after last write operation then it does not affect propagation of changes that are made by transaction. These changes are preserved and there is no need to perform redo operation.

Advantages :

  • This method require fewer disk accesses to perform operation.
  • In this method, recovery from crash is inexpensive and quite fast.
  • There is no need of operations like- Undo and Redo.

Disadvantages :

  • Due to location change on disk due to update database it is quite difficult to keep related pages in database closer on disk.
  • During commit operation, changed blocks are going to be pointed by shadow page table which have to be returned to collection of free blocks otherwise they become accessible.
  • The commit of single transaction requires multiple blocks which decreases execution speed.
  • To allow this technique to multiple transactions concurrently it is difficult.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.