Alireza Kamrani
04/19/2025
Tuning and Troubleshooting Synchronous Redo Transport
Understanding How Synchronous Transport Ensures Data Integrity
The following algorithms ensure data consistency in an Oracle Data Guard synchronous redo transport configuration.
- Log Writer Process (LGWR) redo write on the primary database online redo log and the Data Guard Network Services Server (NSS) redo write to standby redo log are identical.
- The Data Guard Managed Recovery Process (MRP) at the standby database cannot apply redo unless the redo has been written to the primary database online redo log, with the only exception being during a Data Guard failover operation (when the primary is gone).
In addition to shipping redo synchronously, NSS and LGWR exchange information regarding the safe redo block boundary that standby recovery can apply up to from its standby redo logs (SRLs). This prevents the standby from applying redo it may have received, but which the primary has not yet acknowledged as committed to its own online redo logs.
The possible failure scenarios include:
- If primary database LGWR cannot write to online redo log, then LGWR and the instance crash. Instance or crash recovery will recover to the last committed transaction in the online redo log and roll back any uncommitted transactions. The current log will be completed and archived.
- On the standby, the partial standby redo log completes with the correct value for the size to match the corresponding online redo log. If any redo blocks are missing from the standby redo log, those are shipped over (without reshipping the entire redo log).
- If the primary database crashes resulting in an automatic or manual zero data loss failover, then part of the Data Guard failover operation will do "terminal recovery" and read and recover the current standby redo log.
Once recovery finishes applying all of the redo in the standby redo logs, the new primary database comes up and archives the newly completed log group. All new and existing standby databases discard any redo in the online redo logs, flashback to a consistent system change number (SCN), and only apply the archives coming from the new primary database. Once again the Data Guard environment is in sync with the (new) primary database.
Assessing Performance in a Synchronous Redo Transport Environment
When assessing performance in an Oracle Data Guard synchronous redo transport environment (SYNC) it is important that you know how the different wait events relate to each other. The impact of enabling synchronous redo transport varies between applications.
To understand why, consider the following description of work the Log Writer Process (LGWR) performs when a commit is issued.
- Foreground process posts LGWR for commit ("log file sync" starts). If there are concurrent commit requests queued, LGWR will batch all outstanding commit requests together resulting in a continuous strand of redo.
- LGWR waits for CPU.
- LGWR starts redo write ("redo write time" starts).
- For Oracle RAC database, LGWR broadcasts the current write to other instances.
- After preprocessing, if there is a SYNC standby, LGWR starts the remote write (“SYNC remote write” starts).
- LGWR issues local write ("log file parallel write").
- If there is a SYNC standby, LGWR waits for the remote write to complete.
- After checking the I/O status, LGWR ends "redo write time / SYNC remote write".
- For Oracle RAC database, LGWR waits for the broadcast ack.
- LGWR updates the on-disk SCN.
- LGWR posts the foregrounds.
- Foregrounds wait for CPU.
- Foregrounds ends "log file sync".
Use the following approaches to assess performance.
- For batch loads, the most important factor is to monitor the elapsed time, because most of these processes must be completed in a fixed period of time. The database workloads for these operations are very different than the normal OLTP workloads. For example, the size of the writes can be significantly larger, so using log file sync averages does not give you an accurate view or comparison.
- For OLTP workloads, monitor the volume of transactions per second (from Automatic Workload Repository (AWR)) and the redo rate (redo size per second) from the AWR report. This information gives you a clear picture of the application throughput and how it is impacted by enabling synchronous redo transport.
Why the Log File Sync Wait Event is Misleading
Typically, the "log file sync" wait event on the primary database is the first place administrators look when they want to assess the impact of enabling synchronous redo transport (SYNC).
If the average log file sync wait before enabling SYNC was 3ms, and after enabling SYNC was 6ms, then the assumption is that SYNC impacted performance by one hundred percent. Oracle does not recommend using log file sync wait times to measure the impact of SYNC because the averages can be very deceiving, and the actual impact of SYNC on response time and throughput may be much lower than the event indicates.
When a user session commits, the Log Writer Process (LGWR) will go through the process of getting on the CPU, submitting the I/O, waiting for the I/O to complete, and then getting back on the CPU to post foreground processes that the commit has completed. This whole time period is covered by the log file sync wait event. While LGWR is performing its work there are, in most cases, other sessions committing that must wait for LGWR to finish before processing their commits. The size and number of sessions waiting are determined by how many sessions an application has, and how frequently those sessions commit. This batching up of commits is generally referred to as application concurrency.
For example, assume that it normally takes 0.5ms to perform log writes (log file parallel write), 1ms to service commits (log file sync), and on average you are servicing 100 sessions for each commit. If there was an anomaly in the storage tier, and the log write I/O for one commit took 20ms to complete, then you could have up to 2,000 sessions waiting on log file sync, while there would only be 1 long wait attributed to log file parallel write. Having a large number of sessions waiting on one long outlier can greatly skew the log file sync averages.
The output from V$EVENT_HISTOGRAM for the log file sync wait event for a particular period in time is shown in the following table.
V$EVENT_HISTOGRAM Output for the Log File Sync Wait Event
Milliseconds | Number of Waits | Percent of Total Waits |
1 | 17610 | 21.83% |
2 | 43670 | 54.14% |
4 | 8394 | 10.41% |
8 | 4072 | 5.05% |
16 | 4344 | 5.39% |
32 | 2109 | 2.61% |
64 | 460 | 0.57% |
128 | 6 | 0.01% |
The output shows that 92% of the log file sync wait times are less than 8ms, with the vast majority less than 4ms (86%). Waits over 8ms are outliers and only make up 8% of wait times overall, but because of the number of sessions waiting on those outliers (because of batching of commits) the averages get skewed. The skewed averages are misleading when log file sync average waits times are used as a metric for assessing the impact of SYNC.
Understanding What Causes Outliers
♦️Any disruption to the I/O on the primary or standby databases, or spikes in network latency, can cause high log file sync outliers with synchronous redo transport. You can see this effect when the standby system's I/O subsytem is inferior to that of the primary system.
Often administrators host multiple databases such as dev and test on standby systems, which can impair I/O response. It is important to monitor I/O using iostat to determine if the disks reach maximum IOPS, because this affects the performance of SYNC writes.
Frequent log switches are significant cause of outliers. Consider what occurs on the standby when a log switch on the primary occurs, as follows.
- Remote file server (RFS) process on the standby must finish updates to the standby redo log header.
- RFS then switches into a new standby redo log with additional header updates.
- Switching logs forces a full checkpoint on the standby.
This causes all dirty buffers in the buffer cache to be written to disk, causing a spike in write I/O. In a non-symmetric configuration where the standby storage subsystem does not have the same performance as the primary database, this results in higher I/O latency.♦️ - The previous standby redo log must be archived, increasing both read and write I/O.
Effects of Synchronous Redo Transport Remote Writes
When you enable synchronous redo transport (SYNC), you introduce a remote write (remote file server (RFS) write to a standby redo log) in addition to the normal local write for commit processing.
This remote write, depending on network latency and remote I/O bandwidth, can make commit processing time increase. Because commit processing takes longer, you observe more sessions waiting on the Log Writer Process (LGWR) to finish its work and begin work on the commit request, that is, application concurrency has increased. You can observe increased application concurrency by analyzing database statistics and wait events.
Consider the example in the following table.
Affect of Sync Transport Increasing Application Concurrency
SYNC | Redo Rate | Network Latency | TPS from AWR | log file sync average (ms) | log file parallel write average (ms) | RFS random I/O | SYNC remote write average (ms) | Redo write size (KB) | Redo writes |
Defer | 25MB | 0 | 5,514.94 | 0.74 | 0.47 | NA | NA | 10.58 | 2,246,356 |
Yes | 25MB | 0 | 5,280.20 | 2.6 | .51 | .65 | .95 | 20.50 | 989,791 |
Impact | 0 | - | -4% | +251% | +8.5% | NA | NA | +93.8% | -55.9% |
In the above example, enabling SYNC reduced the number of redo writes, but increased the size of each redo write. Because the size of the redo write increased, you can expect the time spent doing the I/O (both local and remote) to increase. The log file sync wait time is higher because there is more work per wait.
♦️However, at the application level, the impact on the transaction rate or the transaction response time might change very little as more sessions are serviced for each commit. This is why it is important to measure the impact of SYNC at the application level, and not depend entirely on database wait events. It is also a perfect example of why log file sync wait event is a misleading indicator of the actual impact SYNC has on the application.
Example of Synchronous Redo Transport Performance Troubleshooting
To look at synchronous redo transport performance, calculate the time spent for local redo writes latency, average redo write size for each write, and overall redo write latency, as shown here.
♦️Use the following wait events to do the calculations.
- local redo write latency = 'log file parallel write'
- remote write latency = ‘SYNC remote write’
- average redo write size per write = ‘redo size’ / ‘redo writes’
- average commit latency seen by foregrounds = 'log file sync'
Statistics from an Automatic Work Repository (AWR) report on an Oracle database are provided in the following table. Synchronous redo transport (SYNC) was enabled to a local standby with a 1ms network latency to compare the performance impact to a baseline with SYNC disabled.
Assessing Synchronous Redo Transport Performance with Oracle Database
Metric | Baseline (No SYNC) | SYNC | Impact |
redo rate (MB/s) | 25 | 25 | no change |
log file sync | 0.68 | 4.60 | +576% |
log file parallel write average (ms) | 0.57 | 0.62 | +8.8% |
TPS | 7,814.92 | 6224.03 | -20.3% |
RFS random I/O | NA | 2.89 | NA |
SYNC remote write average (ms) | NA | 3.45 | NA |
redo writes | 2,312,366 | 897,751 | -61,2% |
redo write size (KB) | 10.58 | 20.50 | +93.8% |
♦️In the above example observe that log file sync waits averages increased dramatically after enabling SYNC. While the local writes remained fairly constant, the biggest factor in increasing log file sync was the addition of the SYNC remote write. Of the SYNC remote write the network latency is zero, so focusing on the remote write into the standby redo log shows an average time of 2.89ms. This is an immediate red flag given that the primary and standby were using the same hardware, and the SYNC remote write average time should be similar to the primary's log file parallel write average time.
In the above example, the standby redo logs have multiple members, and they are placed in a slower performing disk group. After reducing the standby redo logs to a single member, and placing them in a fast disk group, you can see results such as those shown in the following table.
SYNC Performance After Reducing Standby Redo Logs to a Single Member and Placing on a Fast Disk Group
Metric | Baseline (No SYNC) | SYNC | Impact |
redo rate (MB/s) | 25 | 25 | no change |
log file sync | 0.67 | 1.60 | +139% |
log file parallel write | 0.51 | 0.63 | +23.5% |
TPS | 7714.36 | 7458.08 | -3.3% |
RFS random I/O | NA | .89 | NA |
SYNC remote write average (ms) | NA | 1.45 | NA |
redo writes | 2,364,388 | 996,532 | -57.9% |
redo write size (KB) | 10.61 | 20.32 | +91.5% |
Redo Apply Troubleshooting and Tuning
Most Oracle Data Guard configurations should be able to minimize apply lag by troubleshooting and tuning redo apply. Redo apply performance is directly dependent on the performance of the standby systems.
The guidance presented here assumes that the MAA configuration best practices are followed. As a prerequisites, ensure that the Oracle Data Guard Configuration Best Practices are implemented.
Configure Redo Transport Mode
Configure the redo transport service on each configuration member by setting the LogXptModeproperty to one of the following modes.
- ASYNC configures redo transport services for this standby database using the ASYNC and NOAFFIRM attributes of the LOG_ARCHIVE_DEST_n initialization parameter. This mode, along with standby redo log files, enables minimum data loss data protection of potentially less couple seconds with zero performance impact.
- FASTSYNC configures redo transport services for this standby database using the SYNC and NOAFFIRM attributes of the LOG_ARCHIVE_DEST_n initialization parameter. Configure synchronous redo transport mode with the NOAFFIRMattribute (default=AFFIRM) when using maximum availability mode protection mode. This helps to minimize the performance impact of synchronous redo transport by acknowledging the receipt of redo once it has been successfully received and verified within standby memory, but before the redo has been written to the standby redo log. Zero data loss protection is still preserved when only the primary database fails.
- SYNC configures redo transport services for this standby database using the SYNCand AFFIRM attributes of the LOG_ARCHIVE_DEST_n initialization parameter. This mode, along with standby redo log files, is required for configurations operating in either maximum protection mode or maximum availability mode. This redo transport service enables zero data loss data protection to the primary database, but also can incur a higher performance impact if the round trip latency between primary and standby is high (for example, more than 2ms). This option is required for maximum protection mode
Alireza Kamrani
No comments:
Post a Comment