分享

Oracle案例:一次gc buffer busy acquire诊断

 数据和云 2022-02-22
本案例来自某客户两节点rac的一次生产故障,现象是大面积的gc buffer busy acquire导致业务瘫痪。

首先查看1节点AWR头部信息和load profile:

1节点AWR

得到的关键信息点:

  • 对于LCPU 256的系统,AAS=13379.42/59.91=223,说明系统非常繁忙或者遇到了异常等待。

  • sessions异常增长好几倍,DB CPU/DB Time占比非常低,说明是遇到了异常等待。

  • 其余指标都还算正常。

既然是遇到异常等待,那么就看看top event部分:

1节点AWR

可以看到大量的wait class为Cluster的session,top event也看到大量的gc buffer busy acquire等待事件,该等待事件非常常见就不单独解释了,粗略计算cluster等待事件占据了dbtime的90%左右。

当遇到大量Cluster 等待事件的时候,必须先看看RAC Statistics:

1节点AWR

可以看到每秒传输的block以及message都不多,流量也并不大,所以完全没有必要去查看SQL ordered by Cluster Wait Time部分,继续往下看发现Avg global cache cr block receive time (ms)过高,达到了1473ms。判断此次大量的cluster等待是由于接受远端实例发送cr block过慢导致。

gc cr block receive time =  gc cr block (flush time + build time + send time)

从公式可以看出是远端实例的 gc cr block flush time /build time/send time出现了问题,所以此时需要去看看2节点AWR的RAC Statistics:

2节点AWR

可以看到Avg global cache cr block flush time (ms)非常高,关于current block flush redo的行为有很多的介绍,这里就不解释了。对于cr block flush redo的行为,通常在需要从远端实例的current block构造cr block时才会产生。

Normally CR block buffer processing does not include the 'gc cr block flush time’. However, when a CR buffer is cloned from a current buffer that has redo pending, a log flush for a CR block transfer is required. A high percentage is indicative of hot blocks with frequent read after write access.

对于current/cr flush time延迟较高,通常有两种可能:

  • LGWR写性能差;

  • LGWR被阻塞。

所以下一步思路是直接去看看2节点AWR的Background Wait Events和Wait Event Histogram查看LGWR的写性能如何,是否稳定。

2节点AWR

2节点AWR

可以看到2节点LGWR写性能非常稳定,并且延迟也正常。那么就不是LGWR写性能的问题,很有可能是LGWR被阻塞。

2节点AWR

通过top event看到了2节点有大量等待是等待日志切换完成,说明确实LGWR遭到了阻塞,这个时候是时候去分析ash了,可以直接过滤其他信息去单独查看LGWR的ash信息。

SQL> select to_char(sample_time,'yyyy-mm-dd hh24:mi:ss'),program,session_id,event,seq#,BLOCKING_SESSION,BLOCKING_INST_ID from m_ash where program like '%LGWR%' and inst_id=2 order by 1;
TO_CHAR(SAMPLE_TIME PROGRAM SESSION_ID EVENT SEQ# BLOCKING_SESSION BLOCKING_INST_ID
------------------- ------------------------------ ---------- ------------------------------ ---------- ---------------- ----------------
...
2020-03-07 15:44:40 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:41 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:42 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:43 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:44 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:45 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:46 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:47 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:48 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:49 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:50 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:51 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:52 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:53 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:54 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:55 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:56 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:57 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
2020-03-07 15:44:58 oracle@sxdb02 (LGWR) 913 enq: CF - contention 3850 2224 1
...

可以看到从 15:44:40 开始,LGWR就开始等待CF队列,并且一直持续非常长的时间,阻塞会话是节点1的sid为2224的会话。结合之前AWR的分析这里猜测是在 15:44:40 进行了日志切换,因为日志切换需要去读取控制文件。那么下面看看blocking session的信息。

SQL> select to_char(sample_time,'yyyy-mm-dd hh24:mi:ss'),program,session_id,event,seq#,BLOCKING_SESSION,BLOCKING_INST_ID from m_ash where session_id=2224 and inst_id=1 order by 1;
TO_CHAR(SAMPLE_TIME PROGRAM SESSION_ID EVENT SEQ# BLOCKING_SESSION BLOCKING_INST_ID
------------------- ------------------------- ---------- ------------------------------ ---------- ---------------- ----------------
...
2020-03-07 15:37:41 oracle@sxdb01 (M000) 2224 control file sequential read 479
2020-03-07 15:37:42 oracle@sxdb01 (M000) 2224 566
2020-03-07 15:37:43 oracle@sxdb01 (M000) 2224 control file sequential read 632
2020-03-07 15:37:44 oracle@sxdb01 (M000) 2224 control file sequential read 684
2020-03-07 15:37:45 oracle@sxdb01 (M000) 2224 736
2020-03-07 15:37:46 oracle@sxdb01 (M000) 2224 781
2020-03-07 15:37:47 oracle@sxdb01 (M000) 2224 824
2020-03-07 15:37:48 oracle@sxdb01 (M000) 2224 865
2020-03-07 15:37:49 oracle@sxdb01 (M000) 2224 915
2020-03-07 15:37:50 oracle@sxdb01 (M000) 2224 1031
2020-03-07 15:37:51 oracle@sxdb01 (M000) 2224 1183
2020-03-07 15:37:52 oracle@sxdb01 (M000) 2224 control file sequential read 1304
2020-03-07 15:37:53 oracle@sxdb01 (M000) 2224 1400
2020-03-07 15:37:54 oracle@sxdb01 (M000) 2224 1481
2020-03-07 15:37:55 oracle@sxdb01 (M000) 2224 control file sequential read 1631
2020-03-07 15:37:56 oracle@sxdb01 (M000) 2224 control file sequential read 1834
2020-03-07 15:37:57 oracle@sxdb01 (M000) 2224 control file sequential read 1947
2020-03-07 15:37:58 oracle@sxdb01 (M000) 2224 control file sequential read 2052
2020-03-07 15:37:59 oracle@sxdb01 (M000) 2224 control file sequential read 2159
2020-03-07 15:38:00 oracle@sxdb01 (M000) 2224 control file sequential read 2269
2020-03-07 15:38:01 oracle@sxdb01 (M000) 2224 control file sequential read 2404
2020-03-07 15:38:02 oracle@sxdb01 (M000) 2224 control file sequential read 2517
2020-03-07 15:38:03 oracle@sxdb01 (M000) 2224 control file sequential read 2672
2020-03-07 15:38:04 oracle@sxdb01 (M000) 2224 2801
2020-03-07 15:38:05 oracle@sxdb01 (M000) 2224 2857
2020-03-07 15:38:06 oracle@sxdb01 (M000) 2224 2866
2020-03-07 15:38:07 oracle@sxdb01 (M000) 2224 control file sequential read 2893
2020-03-07 15:38:08 oracle@sxdb01 (M000) 2224 3007
2020-03-07 15:38:09 oracle@sxdb01 (M000) 2224 control file sequential read 3111
2020-03-07 15:38:10 oracle@sxdb01 (M000) 2224 3184
2020-03-07 15:38:11 oracle@sxdb01 (M000) 2224 control file sequential read 3218
2020-03-07 15:38:12 oracle@sxdb01 (M000) 2224 control file sequential read 3263
2020-03-07 15:38:13 oracle@sxdb01 (M000) 2224 3304
..

这里看到阻塞进程为1节点的M000,从15:37分就开始持有CF锁一直在读取控制文件,持续了非常久的时间,导致2节点日志切换时,2节点LGWR无法持有CF锁。M000为MMON进程的slave进程,关于MMON进程我们知道通常都是跟AWR有关,为什么会不断的读取控制文件呢?

结合diag产生的systemstate dump里去查看M000的short_stack信息:

Short stack dump: ksedsts()+380<-ksdxfstk()+52<-ksdxcb()+3592<-sspuser()+140<-__sighndlr()+12<-call_user_handler()+868<-sigacthandler()+92<-__pread()+12<-pread()+112<-skgfqio()+532<-ksfd_skgfqio()+756<-ksfd_io()+676<-ksfdread()+640<-kfk_ufs_sync_io()+416<-kfk_submit_io()+260<-kfk_io1()+916<-kfk_transitIO()+2512<-kfioSubmitIO()+408<-kfioRequestPriv()+220<-kfioRequest()+472<-ksfd_kfioRequest()+444<-ksfd_osmio()+2956<-ksfd_io()+1868<-ksfdread()+640<-kccrbp()+496<-kccrec_rbl()+296<-kccrec_read_write()+1680<-kccrrc()+1072<-krbm_cleanup_map()+28<-kgghstmap()+92<-krbm_cleanup_backup_records()+1100<-kraalac_slave_action()+1016<-kebm_slave_main()+744<-ksvrdp()+1928<-opirip()+1972<-opidrv()+748<-sou2o()+88<-opimai_real()+512<-ssthrdmain()+324<-main()+316<-_start()+380
kraalac_slave_action ->krbm_cleanup_backup_records-> krbm_cleanup_map -> kccrrc
这里可以看到M000当时在清理备份记录而去读取的控制文件,从M000 trace或者ash里M000的action name可以看到当时m000的action为Monitor FRA Space,说明是MMON发起slave去做Monitor FRA Space,而FRA空间不足所以触发的清理一些FRA里的备份记录从而读取的控制文件。

知道了M000为何要去读取控制文件,那么下一个问题就是为什么会读那么久呢?控制文件过大?控制文件读取过慢?还是从systemstate dump中找到了答案:

 SO: 0x22e13908e0, type: 10, owner: 0x23012ace68, flag: INIT/-/-/0x00 if: 0x1 c: 0x1
proc=0x23012ace68, name=FileOpenBlock, file=ksfd.h LINE:6688 ID:, pg=0
(FOB) 22e13908e0 flags=2560 fib=22fde0d288 incno=0 pending i/o cnt=0
fname=+FASTDG/sxboss/controlfile/current.256.907844431
fno=1 lblksz=16384 fsiz=118532

控制文件大小为 lblksz* fsiz=16384*118532=1.8g,为何控制文件会那么大呢?

因为control_file_record_keep_time设置为了365天。

解决方案:

1.根据备份策略合理设置 control_file_record_keep_time;

2.重建控制文件。

该案例得到的收获就是平时对MMON进程的作用了解过少,通过KST trace跟踪MMON,发现MMON的作用非常非常多,并不只是与AWR相关。KST trace跟踪到的MMON的action如下:

(MMON) : (infrequent action) : acnum=&#91;133] comment=&#91;deferred controlfile autobackup action]     
(MMON) : (infrequent action) : acnum=&#91;150] comment=&#91;recovery area alert action]
(MMON) : (infrequent action) : acnum=&#91;167] comment=&#91;undo usage]
(MMON) : (infrequent action) : acnum=&#91;171] comment=&#91;Block Cleanout Optim, Undo Segment Scan]
(MMON) : (infrequent action) : acnum=&#91;175] comment=&#91;Flashback Archive RAC Health Check]
(MMON) : (infrequent action) : acnum=&#91;178] comment=&#91;tune undo retention lob]
(MMON) : (infrequent action) : acnum=&#91;179] comment=&#91;MMON Periodic LOB MQL Selector]
(MMON) : (infrequent action) : acnum=&#91;180] comment=&#91;MMON Periodic LOB Spc Analyze ]
(MMON) : (infrequent action) : acnum=&#91;183] comment=&#91;tablespace alert monitor]
(MMON) : (infrequent action) : acnum=&#91;197] comment=&#91;OLS Cleanup]
(MMON) : (infrequent action) : acnum=&#91;205] comment=&#91;Sample Shared Server Activity]
(MMON) : (infrequent action) : acnum=&#91;212] comment=&#91;Compute cache stats in background]
(MMON) : (infrequent action) : acnum=&#91;213] comment=&#91;SPM: Auto-purge expired SQL plan baselines]
(MMON) : (infrequent action) : acnum=&#91;214] comment=&#91;SPM: Check SMB size]
(MMON) : (infrequent action) : acnum=&#91;215] comment=&#91;SPM: Delete excess sqllog$ batches]
(MMON) : (infrequent action) : acnum=&#91;219] comment=&#91;KSXM Advance DML Frequencies]
(MMON) : (infrequent action) : acnum=&#91;220] comment=&#91;KSXM Broadcast DML Frequencies]
(MMON) : (infrequent action) : acnum=&#91;225] comment=&#91;Cleanup client cache server state in background]
(MMON) : (infrequent action) : acnum=&#91;226] comment=&#91;MMON TSM Cleanup]
(MMON) : (infrequent action) : acnum=&#91;296] comment=&#91;alert message cleanup]
(MMON) : (infrequent action) : acnum=&#91;297] comment=&#91;alert message purge]
(MMON) : (infrequent action) : acnum=&#91;298] comment=&#91;AWR Auto Flush Task]
(MMON) : (infrequent action) : acnum=&#91;299] comment=&#91;AWR Auto Purge Task]
(MMON) : (infrequent action) : acnum=&#91;300] comment=&#91;AWR Auto DBFUS Task]
(MMON) : (infrequent action) : acnum=&#91;301] comment=&#91;AWR Auto CPU USAGE Task]
(MMON) : (infrequent action) : acnum=&#91;305] comment=&#91;Advisor delete expired tasks]
(MMON) : (infrequent action) : acnum=&#91;313] comment=&#91;run-once action driver]
(MMON) : (infrequent action) : acnum=&#91;319] comment=&#91;metrics monitoring]
(MMON) : (infrequent action) : acnum=&#91;322] comment=&#91;sql tuning hard kill defense]
(MMON) : (infrequent action) : acnum=&#91;323] comment=&#91;autotask status check]
(MMON) : (infrequent action) : acnum=&#91;324] comment=&#91;Maintain AWR Baseline Thresholds Task]
(MMON) : (infrequent action) : acnum=&#91;325] comment=&#91;WCR: Record Action Switcher]
(MMON) : (infrequent action) : acnum=&#91;331] comment=&#91;WCR: Replay Action Switcher]
(MMON) : (infrequent action) : acnum=&#91;338] comment=&#91;SQL Monitoring Garbage Collector]
(MMON) : (infrequent action) : acnum=&#91;344] comment=&#91;Coordinator autostart timeout]
(MMON) : (infrequent action) : acnum=&#91;348] comment=&#91;ADR Auto Purge Task]
(MMON) : (infrequent action) : acnum=&#91;41] comment=&#91;reload failed KSPD callbacks]
(MMON) : (infrequent action) : acnum=&#91;75] comment=&#91;flashcache object keep monitor]
(MMON) : (interrupt action) : acnum=&#91;108] comment=&#91;Scumnt mount lock]
(MMON) : (interrupt action) : acnum=&#91;109] comment=&#91;Poll system events broadcast channel]
(MMON) : (interrupt action) : acnum=&#91;20] comment=&#91;KSB action for ksbxic() calls]
(MMON) : (interrupt action) : acnum=&#91;2] comment=&#91;KSB action for X-instance calls]
(MMON) : (interrupt action) : acnum=&#91;306] comment=&#91;MMON Remote action Listener]
(MMON) : (interrupt action) : acnum=&#91;307] comment=&#91;MMON Local action Listener]
(MMON) : (interrupt action) : acnum=&#91;308] comment=&#91;MMON Completion Callback Dispatcher]
(MMON) : (interrupt action) : acnum=&#91;309] comment=&#91;MMON set edition interrupt action]
(MMON) : (interrupt action) : acnum=&#91;341] comment=&#91;Check for sync messages from other instances]
(MMON) : (interrupt action) : acnum=&#91;343] comment=&#91;Check for autostart messages from other instances]
(MMON) : (interrupt action) : acnum=&#91;350] comment=&#91;Process staged incidents]
(MMON) : (interrupt action) : acnum=&#91;351] comment=&#91;DDE MMON action to schedule async action slaves]
(MMON) : (interrupt action) : acnum=&#91;39] comment=&#91;MMON request for RLB metrics]
(MMON) : (requested action) : acnum=&#91;314] comment=&#91;shutdown MMON]
(MMON) : (requested action) : acnum=&#91;315] comment=&#91;MMON DB open]
(MMON) : (requested action) : acnum=&#91;321] comment=&#91;ADDM (KEH)]
(MMON) : (requested action) : acnum=&#91;347] comment=&#91;Job Autostart action force]
(MMON) : (requested action) : acnum=&#91;349] comment=&#91;Schedule slave to update incident meter]
(MMON) : (requested action) : acnum=&#91;63] comment=&#91;SGA memory tuning parameter update]
(MMON) : (timeout action) : acnum=&#91;0] comment=&#91;Monitor Cleanup]
(MMON) : (timeout action) : acnum=&#91;11] comment=&#91;Update shared pool advice stats]
(MMON) : (timeout action) : acnum=&#91;154] comment=&#91;Flashback Marker]
(MMON) : (timeout action) : acnum=&#91;172] comment=&#91;Block Cleanout Optim, Rac specific code]
(MMON) : (timeout action) : acnum=&#91;173] comment=&#91;BCO:]
(MMON) : (timeout action) : acnum=&#91;1] comment=&#91;Update KGSTM Translation]
(MMON) : (timeout action) : acnum=&#91;3] comment=&#91;KSB action for bast checking]
(MMON) : (timeout action) : acnum=&#91;42] comment=&#91;reconfiguration MMON action]
(MMON) : (timeout action) : acnum=&#91;63] comment=&#91;SGA memory tuning parameter update]
(MMON) : (timeout action) : acnum=&#91;69] comment=&#91;SGA memory tuning]
。。。

大概有几百种action,平时对MMON关注还是太少了。

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多