Monday, June 29, 2020

Redo Log buffer

What is Redo Log ?

Redo Log plays the most important role in Recovery operations. It consists of two or more preallocated files that store all changes made to the database as they occur. Every instance of an Oracle Database has an associated redo log to protect the database in case of an instance failure.

Redo Log Buffer :  Redo Log Buffer provide the fallowing functions.
  • Records all changes made to the database data blocks
  • Primary Purpose  is recovery
  • Changes recorded within are called redo entries
  • Redo entries contain information to reconstruct or redo changes
  • Size defined by Log_buffer Initialization Parameter

The redo log buffer is an area of memory within the SGA and it is a circular buffer that holds the changes made to the datafile blocks. This Information is called redo entries. Redo Entries contains the information necessary to re-create the data prior to the made by INSERT, UPDATE, DELETE, CREATE, ALTER, or DROP operations.

Server process generates the redo data (redo entries ) into the redo log buffer as any changes occurs to the data blocks using DMLs in the Database buffers.  LGWR (log Writer) database background process writes the redo log buffers (redo entries)  to the Active online Redo Log File on the disk.

Oracle will eventually flush the redo log buffer by transferring the redo entries to Active inline redo log Files on disk. This can happen in a number of special cases.
  • Every commit transaction occurs.
  • When redo Log buffer Fills even though some redo records may not be committed.
  • Until Unless All redo entries are transferred to the active online redo log files on disk.
Whenever a transaction is committed, LGWR writes the transaction redo records from the redo log buffer of the SGA to a redo log file, and assigns a system change number (SCN) to identify the redo records for each committed transaction. Only when all redo records associated with a given transaction are safely on disk in the online logs is the user process notified that the transaction has been committed.

Redo records can also be written to a redo log file before the corresponding transaction is committed. If the redo log buffer fills, or another transaction commits, LGWR flushes all of the redo log entries in the redo log buffer to a active online redo log files on the disk , even though some redo records may not be committed. If necessary, the database can roll back these changes.

Redo entries record data that you can use to reconstruct all changes made to the database, including the undo segments. Therefore, the redo log also protects rollback data. When you recover the database using redo data, the database reads the change vectors in the redo records and applies the changes to the relevant blocks.


Sizing the Redo Log buffer:

The size of the redo log buffer is defines by the LOG_BUFFER initialization parameter.

The default value of this size is four times the DB_BLOCK_SIZE, but it is often desirable to set this value higher, particularly if there are many or long transactions generating high rates of redo generation.


Thank You !!

No comments:

Post a Comment