检测告警日志发现 Private strand flush not complete

本文深入分析了Oracle数据库中遇到的Private strand flush not complete错误,包括其症状、原因、解决方法和相关思考。重点阐述了在高并发环境中数据库系统的工作原理、redo流程、参数设置和优化策略,提供了具体的SQL命令调整示例。

1. 检查告警日志发现Private strand flush not complete

报错如下:

Mon May 23 12:32:34 2016

Thread 1 cannot allocate new log, sequence 6726

Private strand flush not complete

  Current log# 1 seq# 6725 mem# 0: /home/oracle/app/oracle/oradata/qianlong/redo01.log

Thread 1 advanced to log sequence 6726 (LGWR switch)

  Current log# 2 seq# 6726 mem# 0: /home/oracle/app/oracle/oradata/qianlong/redo02.log

 

         下面是自己在网上收集的资料,一起分析分析。

 

2. Meatlink对此的描述

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 May 23 12:32:34 2016

Thread 1 cannot allocate new log, sequence 6726

Private strand flush not complete

  Current log# 1 seq# 6725 mem# 0: /home/oracle/app/oracle/oradata/qianlong/redo01.log

Thread 1 advanced to log sequence 6726 (LGWR switch)

  Current log# 2 seq# 6726 mem# 0: /home/oracle/app/oracle/oradata/qianlong/redo02.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等待事件。所不同的是它仅仅涉及到正在被写入到日志的redoa "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。前者负责将为新的redoredo 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 bufferprivate strand为大量小的私有内存,通常每个大小在64kb-128kb左右,被独立的redo allocation latch所保护。每个特定的小事务会绑定到独立且空闲的private redolog strand,即绑定到一个活动事务。在这种新机制引入后,一旦用户进程申请到private strandredo不再保存的pga中,因此不再需要redo copy latch这个过程。

         如果新事务申请不到private strandredo allocation latch,则会继续遵循旧的redo buffer机制,申请写入shared strand中。由于新机制的引入,相应的redo的产生发生了一些变化,如下:

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

 

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

 

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

4. 处理方案

SQL> show parameter db_w

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_writer_processes                  integer     1

SQL> alter system set db_writer_processes=2 scope=spfile;

SQL> shut immediate

SQL> startup

SQL> show parameter db_w

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_writer_processes                  integer     2

 

-------增加db_writer_processes一定要慎重

----官方建议:

Default value  1 or CPU_COUNT / 8, whichever is greater           默认值为1或CPU个数的1/8

 

[oracle@test ~]$ vmstat 5                ----对CPU当前信息进行采集,每5秒一次

SQL> show parameter cpu_count;                    ----查看当前cpu_count数

SQL> show parameter db_writer_processes;                            ----查看当前数据写进程数

 

 

 

 

reference                            http://www.linuxidc.com/Linux/2013-09/90672.htm

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30130773/viewspace-2106502/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30130773/viewspace-2106502/

本研究聚焦于地级以上城市,对资本、劳动力的空间错配程度进行了系统测度。借助时空核密度和综合协调指数,对城市资源空间错配的集聚模式及协调度展开细致分析,以期揭示城市资源空间错配在时空演变过程中的内在规律。不同资源类型的城市空间错配程度在样本期内呈现出明显差异。城市资本和劳动力的空间错配,未能在不同地区、行业或企业之间实现最优配置,导致资源的边际产出不相等,从而偏离帕累托最优状态,造成效率损失和经济结构失衡。在地级市层面,资源错配问题尤为突出,主要表现为资本、劳动力和土地要素在城市间的配置不均衡。本数据包含原始数据、参考文献、代码、最终结果。原始数据资料:分城市财政收支083045349(仅供vip使用)分城市固定资产投资与消费075134218(仅供vip使用)分城市国内生产总值150425289(仅供vip使用)分城市金融统计文件083120235(到2023年)分城市人口、就业与工资150748455(仅供vip使用)分省份按城乡分全社会国定资产投资075038121(仅供vip使用)分省份固定资产投资价格指数075341115(仅到2019年)分省份国内生产总值150256154(仅供vip使用)分省份人口情况文件152110158(仅供vip使用)指数基本信息文件083840325(仅供vip使用)1998-2023固定资产投资价格指数.xlsxfinancial_data_analysis_report_wsl 20250903_205457.xlsxfinancial data_analysis_report_ wsl 20250903 205457_charts.pngn1.各地区进出口总额年度统计文件(按企业注册类型分).csv樊纲1997-2019年市场化指数和各分项指数.xlsx樊纲1997-2023年市场化指数和各分项指数.xlsx分省份财政金融文件(1995-2023).csv分省份外商投资企业年底注册登记情况.csv复现说明.docx固定资产投资资金来源-年度(分省级).xlsx极速下载 各省资本存量数据2000-2023年(原始数据+测算+结果...相关数据及指标省 地级市 年份 资本错配指数 劳动力错配指数
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值