SMON’s instance recovery with example
EXAMPLE : 1
- In the above diagram, assume that 1,2 and 3 transactions are commited and 4 is going on. Also as checkpoint occurred at log switch, complete data of 1 and 2, also part of 3 were written to datafiles
- Assume LGWR is writing to second file for transaction 4 and instance crash occurred.
- While recovery, SMON will start comparing the SCN between data file header and redo log file. Also it will check for commit point.
- In the above example, 1 & 2 are written and commited. So nothing is there to recover. But for 3, only half data is written. To write other half, SMON will initiate DBWRn. But DBWRn will be unable to do that as dirty blocks are cleaned out from write list. (due to instance restart)
- Now DBWRn will take help of server process which will actually generate dirty blocks with the help of redo entries that are already written to redolog files.
EXAMPLE : 2
- In the above example, transaction 3 is not yet commited, but because log switch occurred and checkpoint event triggred, part of its data is written to datafiles.
- Assume an instance crash occurred and SMON is performing instance recovery.
- SMON will start comparing SCN as usual and when comes to 3 it identifies that data is written to datafiles, but actually 3 is not committed. So this data need to be reverted. Again it will ask DBWRn to take this job.
- DBWRn in turn takes help from server process which will generated blocks with old values with the help of undo tablespace.
Note : For roll forward, redo entries from redolog files will be used where as in rollback before images from undo tablespace will be used.