关于 Private strand flush not complete

简介:       网友发来告警日志,原本是关于一个死锁的情形,而另外的一个问题则是从redo log buffer写出到redo log file出现了不能分配新的日志,Private strand flush not complete的等待事件。

      网友发来告警日志,原本是关于一个死锁的情形,而另外的一个问题则是从redo log buffer写出到redo log file出现了不能分配新的日志,Private strand flush not complete的等待事件。这是个和redo log相关的话题,从Meatlink也找到了对此的描述如下文。

 

1、错误消息

Tue Sep 24 14:27:48 2013
Thread 1 cannot allocate new log, sequence 22120
Private strand flush not complete
  Current log# 4 seq# 22119 mem# 0: /u01/app/oracle/oradata/orcl/redo04.log

 

2、Meatlink 对此的描述(Doc ID 372557.1)

Oracle Database - Enterprise Edition - Version 10.2.0.1 to 11.2.0.3 [Release 10.2 to 11.2]
Information in this document applies to any platform.

Private strand flush not complete

Symptoms

"Private strand flush not complete" messages are being populated to the alert log, example:

Mon Jan 23 16:09:36 2012
Thread 1 cannot allocate new log, sequence 18358
Private strand flush not complete
Current log# 7 seq# 18357 mem# 0: /u03/oradata/bitst/redo07.log
Thread 1 advanced to log sequence 18358
Current log# 8 seq# 18358 mem# 0: /u03/oradata/bitst/redo08.log

Changes

When you switch logs all private strands have to be flushed to the current log before the switch is allowed to proceed.

--切换日值前,所有的private strands必须写入到当前的redo logfile

Cause

The message means that we haven't completed writing all the redo information to the log when we are trying to switch. It is similar in nature to a "checkpoint not complete" except that is only involves the redo being written to the log. The log switch can not occur until all of the redo has been written.
-->该消息意味着在日志切换前我们不能够完整的写出redo到日志文件。其本质类似于checkpoint not complete等待事件。所不同的是它仅仅涉及到正在被写入到日志的redo


A "strand" is new terminology for 10g and it deals with latches for redo .    -->strand是一个用于处理redo latch的新术语

Strands are a mechanism to allow multiple allocation latches for processes to write redo more efficiently in the redo buffer and is related to the log_parallelism parameter present in 9i.

The concept of a strand is to ensure that the redo generation rate for an instance is optimal and that when there is some kind of redo contention then the number of strands is dynamically adjusted to compensate.

-->最大的作用是用于确保redo产生的速率达到最佳,并在出现相关redo竞争的时候动态调整strand的值进行补偿

The initial allocation for the number of strands depends on the number of CPU's and is started with 2 strands with one strand for active redo generation.

For large scale enterprise systems the amount of redo generation is large and hence these strands are *made active* as and when the foregrounds encounter this redo contention (allocated latch related contention) when this concept of dynamic strands comes into play.

There is always shared strands and a number of private strands .

Oracle 10g has some major changes in the mechanisms for redo (and undo), which seem to be aimed at reducing contention.

-->在10g中有很大的变化,最主要的目的还是为了减少竞争

Instead of redo being recorded in real time, it can be recorded 'privately' and pumped into the redo log buffer on commit.

Similarly the undo can be generated as 'in memory undo' and applied in bulk. This affect the memory used for redo management and the possibility to flush it in pieces. The message you get is related to internal Cache Redo File management.

...You can disregard these messages as normal messages.      --->可以当作常规消息被忽略

Solution

These messages are not a cause for concern unless there is a significant time gap between the "cannot allocate new log" message and the "advanced to log sequence" message.   --->如果"cannot allocate new log" 与"advanced to log sequence"有明显的时间间隔,应考虑增加db_writer_processes

Increasing the value for db_writer_processes can in some situations help to avoid the message from being generated. Why, because one of the DBWR main function is to keep the buffer cache clean by writing out dirty buffer blocks. So having multiple db_writer_processes should be able to produce a higher throughput.

Finally, these messages have also been seen when there are issues with the storage side or network for the archive log destination, as this leads to delay or hang in LGWR switch.

 

3、延伸思考

      在高并发,多用户的数据库系统中,所有客户端进程都是通过向redo log buffer写入重做数据来确保数据的完整与一致性。对于redo log buffer的管理,则通过latch的机制来实现。和redo相关的latch主要有两个,一个是redo allocation latch,一个是redo copy latch。前者负责将为新的redo在redo log buffer中分配空间,后者则是pga中的redo复制到redo log buffer。下面是描述一下redo产生的流程。

 

用户进程产生redo(位于PGA中)====>服务器进程获取Redo Copy latch(存在多个取决于CPU_COUNT*2)====>服务进程获取redo allocation latch(仅1个)====>分配log buffer====>释放redo allocation latch====>将Redo Entry写入Log Buffer====>释放Redo Copy latch

 

      如前文Doc ID 372557.1所述,Oracle 9.2之后引入了log_parallelism机制,当该参数的值大于1的时候,数据库会分配多个共享的redo log buffer,也就是说redo log buffer被再次细分,使得每个共享的buffer使用独立的redo allocation latch来进行保护以提高redo的并发性。这些个共享的redo log buffer就被称之为 shared strand。在10gR2以后了又多出了一个private strand,这个东东是从shared pool中分配而不是先前的log buffer。private strand为大量小的私有内存,通常每个大小在64kb-128kb左右,被独立的redo allocation latch所保护。每个特定的小事务会绑定到独立且空闲的private redolog strand,即绑定到一个活动事务。在这种新机制引入后,一旦用户进程申请到private strand,redo不再保存的pga中,因此不再需要redo copy latch这个过程。如果新事务申请不到private strand的redo allocation latch,则会继续遵循旧的redo buffer机制,申请写入shared strand中。由于新机制的引入,相应的redo的产生发生了一些变化,如下:

 

新事务开始====>申请private strand的redo allocation latch(申请失败则申请shared strand的redo allocation latch)====>在private strand中生产redo Entry====>flush/commit====>申请redo copy latch====>LGWR将redo entry批量写入log File====>释放redo copy latch====>释放Private strand的redo allocation latch

     

      对于这个新的机制,在进行redo被写出到logfile时,LGWR需要将shared strand与private strand的内容写出。当redo flush发生时,所有的publicredo allocation latch需要被获取,所有的public strands的redo copy latch需要被检查,所有包含活动事务的private strands需要被持有。

 

      由上可知,Private strand flush not complete事件的出现是通过增加参数DBWn的值来避免。因为DBWn会触发LGWR将redo写入到logfile。

 

Oracle 牛鹏社    Oracle DBsupport

更多参考

有关Oracle RAC请参考
     使用crs_setperm修改RAC资源的所有者及权限
     使用crs_profile管理RAC资源配置文件
     RAC 数据库的启动与关闭
     再说 Oracle RAC services
     Services in Oracle Database 10g
     Migrate datbase from single instance to Oracle RAC
     Oracle RAC 连接到指定实例
     Oracle RAC 负载均衡测试(结合服务器端与客户端)
     Oracle RAC 服务器端连接负载均衡(Load Balance)
     Oracle RAC 客户端连接负载均衡(Load Balance)
     ORACLE RAC 下非缺省端口监听配置(listener.ora tnsnames.ora)
     ORACLE RAC 监听配置 (listener.ora tnsnames.ora)
     配置 RAC 负载均衡与故障转移
     CRS-1006 , CRS-0215 故障一例 
     基于Linux (RHEL 5.5) 安装Oracle 10g RAC
     使用 runcluvfy 校验Oracle RAC安装环境

有关Oracle 网络配置相关基础以及概念性的问题请参考:
     配置非默认端口的动态服务注册
     配置sqlnet.ora限制IP访问Oracle
     Oracle 监听器日志配置与管理
     设置 Oracle 监听器密码(LISTENER)
     配置ORACLE 客户端连接到数据库

有关基于用户管理的备份和备份恢复的概念请参考
     Oracle 冷备份
     Oracle 热备份
     Oracle 备份恢复概念
     Oracle 实例恢复
     Oracle 基于用户管理恢复的处理
     SYSTEM 表空间管理及备份恢复
     SYSAUX表空间管理及恢复
     Oracle 基于备份控制文件的恢复(unsing backup controlfile)

有关RMAN的备份恢复与管理请参考
     RMAN 概述及其体系结构
     RMAN 配置、监控与管理
     RMAN 备份详解
     RMAN 还原与恢复
     RMAN catalog 的创建和使用
     基于catalog 创建RMAN存储脚本
     基于catalog 的RMAN 备份与恢复
     RMAN 备份路径困惑
     使用RMAN实现异机备份恢复(WIN平台)
     使用RMAN迁移文件系统数据库到ASM
     linux 下RMAN备份shell脚本
     使用RMAN迁移数据库到异机

有关ORACLE体系结构请参考
     Oracle 表空间与数据文件
     Oracle 密码文件
     Oracle 参数文件
     Oracle 联机重做日志文件(ONLINE LOG FILE)
     Oracle 控制文件(CONTROLFILE)
     Oracle 归档日志
     Oracle 回滚(ROLLBACK)和撤销(UNDO)
     Oracle 数据库实例启动关闭过程
     Oracle 10g SGA 的自动化管理
     Oracle 实例和Oracle数据库(Oracle体系结构) 

相关实践学习
部署高可用架构
本场景主要介绍如何使用云服务器ECS、负载均衡SLB、云数据库RDS和数据传输服务产品来部署多可用区高可用架构。
负载均衡入门与产品使用指南
负载均衡(Server Load Balancer)是对多台云服务器进行流量分发的负载均衡服务,可以通过流量分发扩展应用系统对外的服务能力,通过消除单点故障提升应用系统的可用性。 本课程主要介绍负载均衡的相关技术以及阿里云负载均衡产品的使用方法。
目录
相关文章
|
4月前
|
Linux Windows
WARNING: UNPROTECTED PRIVATE KEY FILE!
WARNING: UNPROTECTED PRIVATE KEY FILE!
25 0
|
4月前
报错modify sync object Modify sync object Failed!
报错modify sync object Modify sync object Failed!
21 1
|
5月前
|
PHP
set_error_handler()
set_error_handler()
19 0
|
5月前
|
Java 关系型数据库 MySQL
定时任务Quzrtz:Failed to override connection auto commit/transaction isolation
定时任务Quzrtz:Failed to override connection auto commit/transaction isolation
|
8月前
|
数据安全/隐私保护
Do Sync Disk 0 Part 0 Failed, code=S3_F42, msg=Sync Failed after retry 5 times
Do Sync Disk 0 Part 0 Failed, code=S3_F42, msg=Sync Failed after retry 5 times
144 1
|
11月前
|
Oracle 前端开发 关系型数据库
log file sync 和 log file parallel write等待事件的区别和联系
log file parallel write 和log file sync这两个等待事件关系密切,很多人对这两个等待事件有一些误解,我们先来看看Oracle官方文档的解释:
|
SQL Oracle 关系型数据库
Could not find archived log for sequence 587 thread 1 under default destinations SQL
Could not find archived log for sequence 587 thread 1 under default destinations SQL
Could not find archived log for sequence 587 thread 1 under default destinations SQL
Could not obtain transaction-synchronized Session for current thread原因及解决方案
Could not obtain transaction-synchronized Session for current thread原因及解决方案
205 1
Could not obtain transaction-synchronized Session for current thread原因及解决方案
|
测试技术
The concurrent snapshot for publication 'xxx' is not available because it has not been fully generated or the Log Reader Agent is not running to activ
在两台测试服务器部署了复制(发布订阅)后,发现订阅的表一直没有同步过来。重新生成过snapshot ,也重新初始化过订阅,都不能同步数据,后面检查Distributor To Subscriber History, 发现有如下日志信息: The concurrent snapshot for pub...
1505 0