In-order to recover the system after these failures we need to identify the failure modes of those devices used for storage of data. Next, we must consider how these failure modes affect the contents of the database. Then we can propose the recovery algorithms to recover the database. Every Recovery algorithm performs two types of actions. These are:
• Actions taken during normal transaction processing to ensure enough information exists to allow recovery from failure.
• Actions taken following a failure to recover the database to a state that is known to be correct.
We’ll be covering the following topics in this tutorial:
Terminology Used In Recovery Process
Disk is partitioned into fixed length storage units called blocks. Blocks are the units of data transfer to and from disk and may contain several data. When a transaction starts the data required for the transaction is transferred from the disk to main memory (RAM) in\ blocks. When all the operations are performed on the block present in the main memory, then that block is transferred from main memory to disk for the final storage of results. The blocks residing on the disk one called as physical block. The block residing in temporarily on main memory is referred to as Buffer blocks. The area of memory where block reside temporarily is called as disk buffer as shown.
Block movements between disk and main memory are categorized in to following two operations:
• Input Operation: Transfer the physical block to main memory as shown.
• Output Operation: Transfer the buffer block in main memory to the disk and replaces the appropriate physical block as shown.
Work Area of a Transaction
Each transaction Ti has a private work area in which copy of all the data items accessed and updated by Ti are kept. This work area is created when the transaction is initiated and is removed when transaction is completed or cancelled. Each data item X kept in work area of transaction is denoted by Xi.
Example:
Read (A, a)
In order to perform above transaction first we find the data block in disk where A resides.
Suppose that data item A resides. in block X. Then system search for block X in main Memory (RAM). If block is not in main memory then system issue the inputs X command it means block X is copied from disk to main memory. After getting the value block X in main memory then the value of A is copied to temporary variable “a”. Now “a” has value 1000. All the above operations are covered under single read (A, a) operation.
a=a-50
This subtraction is actually performed on local temporary variable “a”. Now it has value 950 as shown in figure.
Write (A, a)
In order to perform above operation first system check that to which block data item A belongs. It is found that A belongs to block X then block X is searched in main memory. If block X is not in main memory then again input X operation is performed. After getting block X in main memory then content of temporary local variable “a” i.e. 950 is copied to database variable A”-Now database item A has value 950 in main memory. Since whole operation is performed in main memory the result of transaction A=950 are stored in main memory as shown in figure. Then in order to store the result in disk output operation is performed.
Output (X)
In case of output (X) block X residing in main memory overwritten in disk. It mean that now the value of data item A=950 is copied to disk permanently and the result of transaction is stored safely as shown in figure.