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
    • "REDO LOG BUFFER"
    • "LGWR"
    • "REDO LOG FILE 1"
    • "REDO LOG FILE 2"
  1. Description of Relevant Features:
    • The image depicts the flow of data from the Redo Log Buffer to the Redo Log Files, facilitated by the Log Writer (LGWR) process.
    • The Redo Log Buffer is shown as a memory structure that holds changes made to the database.
    • The LGWR process is responsible for writing data from the Redo Log Buffer to the physical Redo Log Files on disk.
    • The Redo Log Files (1 and 2) serve as storage for these changes, ensuring that the database can recover from system failures by replaying the log entries.
    • The image emphasizes the sequential and crucial nature of writing redo information to maintain data integrity and support recovery mechanisms.

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.

Oracle RMAN Backup and Recovery

Function of the lgwr for "cloud-enabled" databases 12c to 19c

The fundamental function of the Log Writer (LGWR) process remains the same in cloud-enabled databases (Oracle 12c to 19c) as it was in Oracle 11g: to write redo log buffer entries to redo log files on disk. However, in Oracle 12c and newer cloud-enabled databases, there are enhancements and optimizations designed to support features like multitenancy, in-memory processing, and advanced data replication in cloud environments.
Here are some key points:
  1. Multitenant Architecture (Oracle 12c and later): In a multitenant environment, the LGWR process needs to manage redo information for multiple pluggable databases (PDBs) within a single container database (CDB). This can add complexity to the way redo logs are written and managed but does not change the core responsibility of LGWR.
  2. Cloud Optimizations: Newer versions have optimizations to improve performance and manage latency in distributed cloud environments, but the LGWR still performs the critical task of ensuring that all committed transactions are durably logged.
  3. High Availability and Scalability Enhancements: For cloud-enabled databases, LGWR might be more tightly integrated with features like Oracle Data Guard or Active Data Guard for disaster recovery, ensuring better synchronization and failover capabilities across distributed systems.
Overall, the purpose of LGWR remains unchanged, but the process is more optimized to cater to cloud-based performance and redundancy requirements.
The next lesson describes the function of checkpoints.

SEMrush Software