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:
- 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.
- Write the redo log buffers to the current log file.
- Switch log files: The control file and data file headers are updated indicating the change. The current redo log file is closed.
- Open the new log file: Information indicating the log switch is successful is processed.
The
LGWR
process is diagrammed in the image below.
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:
- A transaction commits
- The redo log buffer becomes one-third full
- More than one megabyte of changed records exists in the redo log buffer
- A timeout occurs (every three seconds)
- 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.