暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Adaptive Log File Sync Optimization (文档 ID 1541136.1)

夏天 2025-01-08
70

Applies to:

Oracle Database - Enterprise Edition - Version 11.2.0.3 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Information in this document applies to any platform.

Goal

The document explains adaptive log file syncs introduced in 11.2 and the supporting parameter "_use_adaptive_log_file_sync" .

Solution

'log file sync' Waits

When a user session commits (or rolls back), the redo information needs to be flushed to the redo logfile. The user session will post the LGWR to write all redo required from the log buffer to the redo log file. The user session waits on ‘log file sync’ while waiting for LGWR to post it back to confirm all redo changes are safely on disk.
For further information on 'log file sync' waits and how to alleviate performance problems arising from high waits see:

Document 1376916.1 Troubleshooting: "log file sync" Waits
Document 34592.1  WAITEVENT: "log file sync"

For a list of known issues in 11.2 see:

Document 1548261.1 High Waits for 'Log File Sync': Known Issue Checklist for 11.2

 

Parameter: _use_adaptive_log_file_sync

The parameter “_use_adaptive_log_file_sync” was introduced in 11gR2 and controls whether adaptive switching between post/wait and polling is enabled.
In 11.2.0.1 and 11.2.0.2 the default value for the parameter is false. From 11.2.0.3, the default value has been changed to true.

“_use_adaptive_log_file_sync” is a dynamic parameter that can be changed at system level.

ALTER SYSTEM SET "_use_adaptive_log_file_sync"= <FALSE/TRUE>  scope=<both/spfile/memory>;
Adpative Log File Sync

There are 2 methods by which LGWR and foreground processes can communicate in order to acknowledge that a commit has completed:

  • Post/wait - traditional method available in previous Oracle releases
    LGWR explicitly posts all processes waiting for the commit to complete.
    The advantage of the post/wait method is that sessions should find out almost immediately when the redo has been flushed to disk.

  • Polling
    Foreground processes sleep and poll to see if the commit is complete.
    The advantage of this new method is to free LGWR from having to inform many processes waiting on commit to complete thereby freeing high CPU usage by the LGWR.

Initially the LGWR uses post/wait and according to an internal algorithm evaluates whether polling is better. Under high system load polling may perform better because the post/wait implementation typically does not scale well. If the system load is low, then post/wait performs well and provides better response times than polling. Oracle relies on internal statistics to determine which method should be used.  Because switching between post/wait and polling incurs an overhead, safe guards are in place in order to ensure that switches do not occur too frequently.

All switches are recorded in LGWR's trace file with a time stamp and the string "Log file sync switching to ...":

Switch to polling:

*** 2012-10-02 08:15:47.049
kcrfw_update_adaptive_sync_mode: post->poll long#=316 sync#=1719 sync=247657
poll=12382 rw=6191 rw+=13890 ack=0 min_sleep=10023


*** 2012-10-02 08:15:47.050
Log file sync switching to polling
Current scheduling delay is 234 usec

 
Switch to post/wait:

***2012-10-02 08:16:23.325
kcrfw_update_adaptive_sync_mode: poll->post current_sched_delay=0
switch_sched_delay=234 current_sync_count_delta=2275
switch_sync_count_delta=1719

*** 2012-10-02 08:16:23.325
Log file sync switching to post/wait
Current approximate redo synch write rate is 758 per sec 

 
Statistics on polling are stored in v$sysstat:

SQL> select name,value from v$sysstat where name in ('redo synch poll writes','redo synch polls');

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
redo synch poll writes                                                    0
redo synch polls                                                          0

In the above example we see that polling is not occurring

The statistics are also included in the AWR report:

AWR polling stats

In the above AWR we see that polling is occurring

Known Issues with "_use_adaptive_log_file_sync" set to TRUE

In the vast majority of cases adaptive log file sync improves the overall performance of log file  synchronisation.
Following is a list of known issues.
As these issues are fixed in 11.2.0.4 and 12.1, it is advisable to be at least on one of these versions in order to avoid the known issues.

Document 1462942.1 Adaptive Switching Between Log Write Methods can Cause 'log file sync' Waits
Document 13707904.8 Bug 13707904 - LGWR sometimes uses polling, sometimes post/wait
Document 13074706.8 Bug 13074706 - Long "log file sync" waits in RAC not correlated with slow writes
Document 25178179.8 Bug 25178179 - Several sessions wait on 'log file sync' in a RAC environment

If there is a need to disable adaptive log file sync this can be done by setting _use_adaptive_log_file_sync = false either in the spfile and restarting the database or dynamically in memory. 



References

NOTE:1318709.1 - AIX: Long "log file sync" Wait Time in 11.2. : Things To Check

NOTE:13707904.8 - Bug 13707904 - LGWR sometimes uses polling, sometimes post/wait



NOTE:10318123.8 - Bug 10318123 - Solaris: LGWR regularly stalls for 3 seconds at a time
NOTE:1462942.1 - Adaptive Switching Between Log Write Methods can Cause 'log file sync' Waits
NOTE:13551402.8 - Bug 13551402 - High "log file parallel write" and "log file sync" after upgrading 11.2 with Veritas/Symantec ODM
NOTE:1376916.1 - Troubleshooting: 'Log file sync' Waits

NOTE:13074706.8 - Bug 13074706 - Long "log file sync" waits in RAC not correlated with slow writes
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论