`

Oracle Log File Sync Wait Event

 
阅读更多

The Oracle “log file sync” wait event is triggered when a user session issues a commit (or a rollback). The user session will signal or post the LGWR to write the log buffer to the redo log file. When the LGWR has finished writing, it will post the user session. The wait is entirely dependent on LGWR to write out the necessary redo blocks and send confirmation of its completion back to the user session. The wait time includes the writing of the log buffer and the post, and is sometimes called “commit latency”.

 

The P1 parameter in <View:V$SESSION_WAIT> is defined as follows for the log file sync wait event:

 

P1 = buffer#
All changes up to this buffer number (in the log buffer) must be flushed to disk and the writes confirmed to ensure that the transaction is committed and will be kept on an instance crash. The wait is for LGWR to flush up to this buffer#.

 

Reducing Oracle waits / wait times

 

If a SQL statement is encountering a significant amount of total time for this event, the average wait time should be examined. If the average wait time is low, but the number of waits is high, then the application might be committing after every row, rather than batching COMMITs. Oracle applications can reduce this wait by committing after “n” rows so there are fewer distinct COMMIT operations. Each commit has to be confirmed to make sure the relevant REDO is on disk. Although commits can be “piggybacked” by Oracle, reducing the overall number of commits by batching transactions can be very beneficial.

 

If the SQL statement is a SELECT statement, review the Oracle Auditing settings. If Auditing is enabled for SELECT statements, Oracle could be spending time writing and commit data to the AUDIT$ table.

 

If the average wait time is high, then examine the other log related waits for the session, to see where the session is spending most of its time. If a session continues to wait on the same buffer# then the SEQ# column of V$SESSION_WAIT should increment every second. If not then the local session has a problem with wait event timeouts. If the SEQ# column is incrementing then the blocking process is the LGWR process. Check to see what LGWR is waiting on as it may be stuck.

 

If the waits are because of slow I/O, then try the following:

 

  • Reduce other I/O activity on the disks containing the redo logs, or use dedicated disks.
    • Try to reduce resource contention. Check the number of transactions (commits + rollbacks) each second, from V$SYSSTAT.
  • Alternate redo logs on different disks to minimize the effect of the archiver on the log writer.
  • Move the redo logs to faster disks or a faster I/O subsystem (for example, switch from RAID 5 to RAID 1).
  • Consider using raw devices (or simulated raw devices provided by disk vendors) to speed up the writes.
  • See if any activity can safely be done with NOLOGGING / UNRECOVERABLE options in order to reduce the amount of redo being written.
  • See if any of the processing can use the COMMIT NOWAIT option (be sure to understand the semantics of this before using it).
  • Check the size of the log buffer as it may be so large that LGWR is writing too many blocks at one time.

 

Log file sync wait event: other considerations

 

There may be a problem with LGWR’s ability to flush redo out quickly enough if Oracle “log file sync” waits are significant for the entire system. The overall wait time for “log file sync” can be broken down into several components. If the system still shows high “log file sync” wait times after completing the general tuning tips above, break down the total Oracle wait time into the individual components. Then, tune those components that take up the largest amount of time.

 

The “log file sync” wait event may be broken down into the following components:

 

1. Wakeup LGWR if idle
2. LGWR gathers the redo to be written and issues the I/O
3. Wait time for the log write I/O to complete
4. LGWR I/O post processing
5. LGWR posting the foreground/user session that the write has completed
6. Foreground/user session wakeup

 

Tune the system based on the “log file sync” component with the most wait time. Steps 2 and 3 are accumulated in the “redo write time” statistic. (i.e. as found under STATISICS section of Statspack) Step 3 is the “log file parallel write” wait event. (See Metalink Note 34583.1:”log file parallel write”) Steps 5 and 6 may become very significant as the system load increases. This is because even after the foreground has been posted it may take some time for the OS to schedule it to run.

 

Data Guard note

 

If Data Guard with synchronous transport and commit WAIT defaults is used, the above tuning steps will still apply. However step 3 will also include the network write time and the redo write to the standby redo logs. The “log file sync” wait event and how it applies to Data Guard is explained in detail in the MAA OTN white paper – Note 387174.1:MAA – Data Guard Redo Transport and Network Best Practices.

 

Final thoughts

 

When a user session waits on the “log file sync” event, it is actually waiting for the LGWR process to write the log buffer to the redo log file and return confirmation/control back to it. If the total wait time is significant, review the average wait time. If the average wait time is low but the number of waits is high, reduce the number of commits by batching (or committing after “n”) rows.

 

If slow I/O, investigate the following:

 

  • Reduce contention on existing disks.
  • Put log files on faster disks.
  • Put alternate redo logs on different disks to minimize the effect archive processes (log files switches).
  • Review application design, use NOLOGGING operations where appropriate, and avoid changing more data than required.

 

If wait times are still significant, review each component of the “log file sync” and tune separately.

 

 

参考至:https://logicalread.com/oracle-log-file-sync-wait-event-dr01/

 

如有错误,欢迎指正

 

邮箱:czmcj@163.com

分享到:
评论

相关推荐

    LOG FILE SYNC概述

    【LOG FILE SYNC】是Oracle数据库中常见的等待事件,主要涉及事务提交、回滚、DDL操作以及数据字典的修改。当事务执行完一系列操作后,需要将redo日志记录写入磁盘,以保证数据的一致性和持久性,此时就会发生LOG ...

    Oracle log file sync等待事件优化浅析.pdf

    Oracle log file sync等待事件优化浅析.pdf

    Tanel_Poder_log_file_sync

    图文并茂,非常详细的介绍Log File Sync机制,对oracle调优很有帮助

    oracle 12c far sync instance

    3. 重命名 redo logfile:在主数据库上进行redo日志文件的重命名操作,这有助于far sync instance识别并跟踪redo日志的变化。 4. 添加 standby logfiles:在主数据库上添加standby日志文件,这些文件会被far sync ...

    数据库性能监控

    log file sync(ms) db file scattered read(ms) #IO WorkLoad Oracle IOPS Oracle MBPS db file sequential read db file scattered read log file parallel write log file sync physical reads physical writes ...

    EventLog Analyzer产品介绍

    同时,EventLog Analyzer也可以审核SQL Server和Oracle数据库活动,跟踪用户操作、DML和DDL查询、数据库更改以及服务器帐户更改。 EventLog Analyzer是一个功能强大且灵活的日志管理和审计SIEM解决方案,能够满足...

    EventLog_Analyzer.zip

    Eventlog Analyzer日志管理系统、日志分析工具、日志服务器的功能及作用  Eventlog Analyzer是用来分析和审计系统及事件日志的管理软件,能够对全网范围内的主机、服务器、网络设备、数据库以及各种应用服务系统等...

    Oracle Wait Interface性能诊断与调整实践指南

    例如,"db file sequential read"表示数据文件的顺序读取,"log file sync"则意味着日志文件同步,这些都是常见的等待事件。 在实践中,分析等待事件通常涉及以下步骤: 1. **收集等待事件数据**:使用如`v$session...

    oracle日志文件相关命令

    ALTER DATABASE ADD LOGFILE MEMBER '/home1/oracle/oradata/ora8i/log1a.log' TO GROUP 1, '/home1/oracle/oradata/ora8i/log2a.log' TO GROUP 2; 该命令将增加两个新的日志成员 log1a.log 和 log2a.log 到对应的...

    oracle自动建立表分区脚本

    在Oracle数据库管理中,表分区是一项重要的优化技术,它能够提高大数据量表的查询性能、管理和维护效率。Oracle DBA(数据库管理员)经常需要对大表进行分区操作,以优化数据库的性能。"Oracle自动建立表分区脚本...

    oracle乱码解决功能!!!

    oracle乱码解决功能 Oracle乱码解决功能是指在使用Oracle数据库时,汉字显示异常的解决方法。这种问题的产生是由于字符集的设置不当所致。字符集是Oracle为适应不同语言文字显示而设定的,用于汉字显示的字符集...

    Log4Net Oracle

    Log4Net Oracle 是一个结合了Log4Net日志框架与Oracle数据库存储的日志管理解决方案。Log4Net是Apache软件基金会的开源项目,它为.NET应用程序提供了一种强大的日志记录工具,而Oracle则是全球广泛使用的大型关系型...

    诗檀软件-基于Oracle 12c Far Sync+Active Data Guard ADG的灾备两地三中心搭建手册】.pdf

    - 添加standby logfile:为备库创建日志文件。 7. **创建备库**: - 配置备库的环境变量。 - 配置hosts文件,确保备库与主库之间的通信。 - 在主库执行相关操作,例如生成参数文件和密码文件。 - 将参数文件、...

    ORACLE 修改redo日志文件 大小的方法

    4. **参数调整**:根据新的redo日志文件大小,可能需要相应地调整Oracle数据库的其他参数,如`LOG_FILE_NAME_CONVERSION`等,以确保数据库的正常运行。 通过以上步骤和注意事项,可以有效地调整Oracle数据库的redo...

    oraclev$sessionv$session_wait用途详解

    1. **等待事件类型**:`EVENT`字段列出了具体的等待事件名称,如“db file sequential read”表示顺序读取数据库文件,“enq: TX - row lock contention”表示行级锁竞争。 2. **等待时长**:`TIME_WAITED`字段提供...

    seata-oracle版undolog.sql

    oracle版本的undolog建表语句。 2019 年 1 月,阿里巴巴中间件团队发起了开源项目 Fescar(Fast & EaSy Commit And Rollback),和社区一起共建开源分布式事务解决方案。Fescar 的愿景是让分布式事务的使用像本地...

    Oracle中password file的作用及说明

    Oracle中password file的作用及说明

    《Oracle Wait Interface性能诊断与调整实践指南》

    ### Oracle Wait Interface (OWI)性能诊断与调整实践指南 #### 一、Oracle Wait Interface (OWI)概述 Oracle Wait Interface(简称OWI)是Oracle数据库管理系统中的一个重要组成部分,主要用于监控和诊断数据库...

    oracle日志alter.log每天切割脚本

    ### Oracle日志Alter.log每天切割脚本解析 在Oracle数据库管理与维护中,日志文件管理是一项非常重要的工作。为了确保系统的稳定运行以及方便后期的日志审计与问题追踪,合理地管理和定期切割日志文件是必不可少的...

Global site tag (gtag.js) - Google Analytics