Undo segments and reading consistency
What happens when a user reads data records that are currently part of another user's ongoing transaction? To clarify this problem, another component of the architecture must be discussed. If a user changes a data record, a copy of the block in which the change is to take place is created beforehand. The copy is created by loading an empty undo block from the so-called undo segments into the database buffer cache and copying the block to be changed into this empty block. This means that there are two blocks in the database buffer cache that are involved in the change. The actual change to the data record is only made after a copy of the block to be changed has been created. This means that the changed block and the block in its original state are in the cache. This original block is also known as the before image in Oracle.
Fig.8: Creating an UNDO block when a data record is changed. © Marek Adar
Fig.8: Creating an UNDO block when a data record is changed. © Marek Adar
If the transaction has not afghanistan telegram screening yet been committed with a COMMIT, all users who want to read the data record access the undo block. They therefore still see the old value of the data record until the transaction is completed with a COMMIT. Reading the original block or undo block of a running transaction is referred to as read consistency. If the user wants to undo his transaction with a ROLLBACK, all changes belonging to this transaction are rolled back via the undo blocks, since the original state is present in them.
Undo segments are needed, among other things, for transaction rollback and to maintain the read consistency of the database.
Fig. 9: How instance recovery works. © Marek Adar
Fig. 9: How instance recovery works. © Marek Adar
If an instance terminates, the data changes in the database buffer cache that have not yet been transferred to the database must be restored via the redo log files after the instance is restarted. This process is called instance recovery and is carried out fully automatically by the background process SMON (System Monitor) when the instance is restarted.