Redolog Buffer Cache : SGA Component of Oracle
- The redo log buffer is a circular buffer in the SGA that stores redo entries describing changes made to the database. Redo entries contain the information necessary to reconstruct, or redo, changes made to the database by DML or DDL operations. Database recovery applies redo entries to data files to reconstruct lost changes.
- Oracle Database processes copy redo entries from the user memory space to the redo log buffer in the SGA. The redo entries take up continuous, sequential space in the buffer. The background process log writer (LGWR) writes the redo log buffer to the active online redo log group on disk.
- The Log Writer (LGWR) process is a crucial background process in Oracle Database that manages the writing of redo entries from the redo log buffer to the online redo log files on disk. This process ensures that all changes made to the database are recorded in a way that can be recovered in the event of a failure.
- LGWR is responsible for writing the contents of the redo log buffer to the online redo log files. This operation ensures that all committed transactions are safely stored on disk
- By writing redo entries to disk in batches, LGWR optimizes I/O operations and ensures that the system’s performance remains high. The continuous, sequential nature of the redo log buffer allows for efficient disk writes.
- As transactions modify data, redo entries are generated and stored in the redo log buffer. These entries describe the changes made by the transactions. The redo log buffer is managed as a circular buffer. When the buffer is full or reaches a specific threshold, LGWR initiates the writing process to free up space for new entries. LGWR writes the redo entries from the redo log buffer to the current online redo log file. This process is crucial for maintaining data integrity and supporting database recovery operations.
The database has three redo latches to handle this process:
- Redo Allocation Latch:This latch is used to serialize the allocation of space within the redo log buffer. When a transaction generates redo entries, it must allocate space in the redo log buffer. The redo allocation latch ensures that this allocation process is done without conflicts.
- Redo Copy Latch:The redo allocation latch is acquired to allocate memory space in the log buffer. Before Oracle9.2, the redo allocation latch is unique and thus serializes the writing of entries to the log buffer cache of the SGA. In Oracle 9.2. Enterprise Edition, the number of redo allocation latches is determined by init.ora LOG_PARALLELISM. The redo allocation latch allocates space in the log buffer cache for each transaction entry. If transactions are small, or if there is only one CPU on the server, then the redo allocation latch also copies the transaction data into the log buffer cache. If a log switch is needed to get free space this latch is released as well with the redo copy latch.
- Redo Writing Latch:This latch is used by the Log Writer (LGWR) process when it writes the contents of the redo log buffer to the online redo log files on disk. The redo writing latch ensures that the write operation is serialized to maintain data consistency and integrity.