Thursday, September 22, 2011

SMON - How it will handle instance recovery

Instance recovery occurs in two steps:
1.Cache Recovery
2.Transaction Recovery
Cache recovery:
Changes being made to a database are recorded in the database buffer cache. These changes are also recorded in online redo log files simultaneously.
When there are enough data in the database buffer cache, they are written to data files.
If an Oracle instance fails before the data in the database buffer cache are written to data files, Oracle uses the data recorded in the online redo log files to recover the lost data when the associated database is re-started. This process is called cache recovery.

Transaction recovery:
When a transaction modifies data in a database, the before image of the modified data is stored in an undo segment.The data stored in the undo segment is used to restore the original values in case a transaction is rolled back. At the time of an instance failure, the database may have uncommitted transactions. It is possible that changes made by these uncommitted transactions have gotten saved in data files.(We don't have any mechanism to track this)
To maintain read consistency, Oracle rolls back all uncommitted transactions when the associated database is re-started. Oracle uses the undo data stored in undo segments to accomplish this. This process is called transaction recovery.