What Is Recovery?
During the life of a transaction, i.e., a after the start of a transaction but before the transaction commits, various changes may be made in a database state. The database through such a state is in an inconsistent state. What occurs when a failure occurs at this stage? Let us define this with the help of an example:
Suppose that a transaction transfers Rs.2000/- from A's account to B's account. For simplicity we are not showing any error checking in the transaction. The transaction may be written as:
A = A - 2000
B = B + 2000
WRITE B COMMIT
What would occur if the transaction fails after account A has been written back to database? As far as the holder of account A is concerned s/he has transferred the money but that has never been taken by account holder B.
Why did this trouble occur? Because although a transaction is considered to be atomic, yet it has a life cycle during which the database gets into an inconsistent state and failure has happened at that stage.
What is the solution? In this situation where the transaction has not yet committed the changes made by it, the partial updates require to be undone.
How can we do that? By remembering information about a transaction such as when did it begin, what items it updated etc. All such details are occurred in a log file.