Describe how Log Writer writes out redo log records.
Log Writer (LGWR)
Describe how the Log Writer writes out redo log records. Every Oracle instance will have a Log Writer process (LGWR) that is responsible for writing out redo log entries to the redo log files.
Unlike the database writer, an instance may have only one log writer. The Log Writer writes redo log entries from an area in the SGA known as the redo log buffer. The redo log buffer is a circular buffer, and conceptually looks like this:
As changes are made to the database, redo log entries are added to the head of the log, and the head pointer is advanced.
The LGWR process is constantly working from the other end of the log, the tail, and constantly writes redo log entries to disk. The next lesson explains this in more detail.
Log Writer Process (LGWR)
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.
The redo log buffer is a circular buffer. When LGWR writes redo entries from the redo log buffer to a redo log file, server processes can then copy new entries over the entries in the redo log buffer that have been written to disk.
LGWR normally writes fast enough to ensure that space is always available in the buffer for new entries, even when access to the redo log is heavy. 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
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 log. 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.