Memory Processes   «Prev  Next»
Lesson 6What is LGWR?
ObjectiveLearn about log writer functions.

log writer functions (lgwr)

The log writer process writes the redo log buffer entries to the redo log files on disk. This process starts automatically when the instance starts. There must be at least two online redo log files for an Oracle instance to operate. LGWR writes to one redo log file at a time. This is the current or active log. When this log file fills up, LGWR performs a log switch and begins writing to the next available log file. If the next available log file is being archived, LGWR will wait until it becomes available. This process has the following steps:
  1. Find the next log file: Oracle will search for an available log file to switch to. Information is stored in case this process fails in mid-stream.
  2. Write the redo log buffers to the current log file.
  3. Switch log files: The control file and data file headers are updated indicating the change. The current redo log file is closed.
  4. Open the new log file: Information indicating the log switch is successful is processed.

The LGWR process is diagrammed in the image below.

Logwriter process
1) Logwriter process

Log writer

At any given time, one redo log group is the current group. The LGWR process is responsible for writing to members of the current redo log group. The LGWR process performs a write when one of the following criteria is met:
  1. A transaction commits
  2. The redo log buffer becomes one-third full
  3. More than one megabyte of changed records exists in the redo log buffer
  4. A timeout occurs (every three seconds)
  5. At every checkpoint

LGWR writes to the redo log groups in a circular fashion. It continues writing to the current group until it becomes filled. When it fills, a log switch occurs and LGWR will start writing the next group. This will continue until the last group fills at which point LGWR will start writing to the first group again. Overwriting those redo log files.
The next lesson describes the function of checkpoints.