Sunday, July 24, 2016

Oracle redo and undo

Changing data in database generated both redo and undo records. The undo record is saved in the undo tablespace. These undo records provide the read consistency feature will allow another transaction to refers to the old version of data while it is being changed (and not committed) depending on the isolation level. The undo record is also used for roll back. The undo record is tied to the data block via pointers (undo block address and record number). The pointer is recorded in the interested transaction list with a limited size. When the list is exceeded, oracle will return error message saying old version data is not accessible. 

Writing the undo record to undo tablespace generated redo records too. The redo records for the real change and the undo record are combined when writing to the log files. 

Each transaction has a private redo (strand) and undo buffer to reduce latch contention to the public redo log buffer. The redo and undo record will be written to the public buffer when transaction commits.