Redo Log Buffer (Oracle DB)

Submitted by UMBRO
on September 5, 2007 - 11:19pm

The redo log buffer is a circular buffer in the SGA that holds information about changes made to the database. This information is stored in redo entries. Redo entries contain the information necessary to reconstruct, or redo, changes made to the database by INSERT, UPDATE, DELETE, CREATE, ALTER, or DROP operations. Redo entries are used for database recovery, if necessary.

Redo entries are copied by Oracle database processes from the user’s memory space to the redo log buffer in the SGA. The redo entries take up continuous, sequential space in the buffer. The background process LGWR writes the redo log buffer to the active redo log file (or group of files) on disk.

The initialization parameter LOG_BUFFER determines the size (in bytes) of the redo log buffer. In general, larger values reduce log file I/O, particularly if transactions are long or numerous. The default setting is either 512 kilobytes (KB) or 128 KB times the setting of the CPU_COUNT parameter, whichever is greater.

The log writer process (LGWR) is responsible for redo log buffer management—writing the redo log buffer to a redo log file on disk.LGWR writes all redo entries that have been copied into the buffer since the last time it wrote.

LGWR writes one contiguous portion of the buffer to disk. LGWR writes:
■ A commit record when a user process commits a transaction
■ Redo log buffers
– Every three seconds
– When the redo log buffer is one-third full
When a DBWn process writes modified buffers to disk, if necessary

Note: Before DBWn can write a modified buffer, all redo records associated with the changes to the buffer must be written to disk (the write-ahead protocol). If DBWn finds that some redo records have not been written, it signals LGWR to write the redo records to disk and waits for LGWR to complete writing the redo log buffer before it can write out the data buffers.

LGWR writes synchronously to the active mirrored group of redo log files. If one of the files in the group is damaged or unavailable, LGWR continues writing to other
files in the group and logs an error in the LGWR trace file and in the system alert file. If all files in a group are damaged, or the group is unavailable because it has not been archived, LGWR cannot continue to function.

When a user issues a COMMIT statement, LGWR puts a commit record in the redo log buffer and writes it to disk immediately, along with the transaction’s redo entries. The corresponding changes to data blocks are deferred until it is more efficient to write them. This is called a fast commit mechanism. The atomic write of the redo entry containing the transaction’s commit record is the single event that determines the transaction has committed. Oracle returns a success code to the committing transaction, although the data buffers have not yet been written to disk.

Note: Sometimes, if more buffer space is needed, LGWR writes redo log entries before a transaction is committed. These entries become permanent only if the transaction is later committed.

When a user commits a transaction, the transaction is assigned a system change number (SCN), which Oracle records along with the transaction’s redo entries in the redo log. SCNs are recorded in the redo log so that recovery operations can be synchronized in Real Application Clusters and distributed databases.
In times of high activity, LGWR can write to the redo log file using group commits.For example, assume that a user commits a transaction. LGWR must write the transaction’s redo entries to disk, and as this happens, other users issue COMMIT statements. However, LGWR cannot write to the redo log file to commit these transactions until it has completed its previous write operation. After the first transaction’s entries are written to the redo log file, the entire list of redo entries of waiting transactions (not yet committed) can be written to disk in one operation,requiring less I/O than do transaction entries handled individually. Therefore, Oracle minimizes disk I/O and maximizes performance of LGWR. If requests to commit continue at a high rate, then every write (by LGWR) from the redo log buffer can contain multiple commit records.

http://en.wikipedia.org/wiki/

on
September 6, 2007 - 2:59am

http://en.wikipedia.org/wiki/Redo_log

Oracle redo log files contain the following information about database changes made by transactions:

* indicators specifying when the transaction started
* a transaction-identifier
* the name of the data object updated (for example, an application table)
* the “before image” of the transaction (the data as it existed before the changes)
* the “after image” of the transaction (the data as it appeared after the transaction made the changes)
* commit-indicators that record whether and when the transaction completed

http://www.oracle.com/technol

on
September 6, 2007 - 3:02am

http://www.oracle.com/technology/oramag/oracle/05-jul/o45dba.html

Because undo segments are also database changes, they generate redo entries as well, which go into online redo logs and then to archived logs.

As a result, online and archived logs contain both undo and redo information.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.