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.
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:
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.
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:
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.
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.
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.