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.

ORACLE从11gR2开始,oracle写日志引入了polling机制,在此之前只有post/wait机制。为了能在两个机制之间进行自适应切换,引入了一个隐含参数"useadaptivelogfilesync"。在11.2.0.3之前,参数的默认值为false,仅启用post/wait机制。从11.2.0.3开始,默认值为true,即lgwr进程在写出日志时会选择在post/wait机制和polling机制进行自适应切换。

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.

Post/wait进制下,lgwr进程在将日志写入磁盘后,会立刻通知前台进程,log file sync等待时间相对较短,但因12C以下oracle数据库中的lgwr进程只有1个,大并发的commit会导致lgwr进程非常繁忙,cpu居高不下。lgwr与其他进程相比,更可能成为数据库的性能瓶颈。

Polling模式下,lgwr进程执行写入操作后不再单独通知前台进程写已经完成,前台进程使用定时查询的方式对写出的进度进行检查。优点是LGWR不必通知等待提交完成的许多进程,从而释放LGWR的高CPU使用率,但是会使前台进程长时间处于log file sync等待。对于交易型的系统该参数应设置为false。

启用该特性会在awr中看到redo synch poll writes、redo synch polls相关的数据不为0。同时,在lgwr的trace文件中能看到Log file sync switching to post/wait、Log file sync switching to polling等相关信息。

关闭方法:

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

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 1541136.1 Adaptive Log File Sync Optimization