[20191126]探究等待事件的本源2.txt

--//做一个测试,验证如果写入控制文件慢也会影响提交性能.

1.环境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SCOTT@book> create table t ( a number ) ;
Table created.

SCOTT@book> insert into t values (1);
1 row created.

SCOTT@book> commit ;
Commit complete.

$ ps -ef | grep lgw[r]
oracle   62683     1  0 Nov25 ?        00:00:09 ora_lgwr_book
--//pid=62683.

$ ls -l /proc/62683/fd/25[67]
lrwx------ 1 oracle oinstall 64 2019-11-26 08:53:07 /proc/62683/fd/256 -> /mnt/ramdisk/book/control01.ctl
lrwx------ 1 oracle oinstall 64 2019-11-26 08:53:07 /proc/62683/fd/257 -> /mnt/ramdisk/book/control02.ctl
--//控制文件句柄是256,257.

$ cat pw.gdb
break *pwrite if $rdi==256
c
--//如果文件句柄256存在写入,中断执行.

2.启动gdb,测试:
--//session 1:
SCOTT@book> select sysdate from dual ;
SYSDATE
-------------------
2019-11-26 08:54:14

--//session 2:
$ gdb -p 62683 -x  pw.gdb
...

Breakpoint 1, 0x000000379a00e600 in pwrite64 () from /lib64/libpthread.so.0
(gdb)

--//session 3:
SYS@book> alter system switch logfile ;
--//挂起!!

--//session 1:
SCOTT@book> @ wait
P1RAW            P2RAW            P3RAW                    P1         P2         P3        SID    SERIAL#       SEQ# EVENT                                    STATUS   STATE               WAIT_TIME_MICRO SECONDS_IN_WAIT WAIT_CLASS
---------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------------------------------- -------- ------------------- --------------- --------------- --------------------
00               00               00                        0          0          0         86        559         17 switch logfile command                   ACTIVE   WAITING                     9280572               9 Administrative
0000000000000002 0000000000000015 0000000000000002          2         21          2        183          1      20011 control file parallel write              ACTIVE   WAITING                     9280236               9 System I/O
--//可以发现当前是日志切换,写入控制文件时设置断点,导致session 3挂起!!

SCOTT@book> insert into t values (3);
1 row created.

SCOTT@book> commit ;
--//挂起!!

--//session 4:
SYS@book> @ wait
P1RAW            P2RAW            P3RAW                    P1         P2         P3        SID    SERIAL#       SEQ# EVENT                                    STATUS   STATE               WAIT_TIME_MICRO SECONDS_IN_WAIT WAIT_CLASS
---------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------------------------------- -------- ------------------- --------------- --------------- --------------------
00               00               00                        0          0          0         86        559         17 switch logfile command                   ACTIVE   WAITING                    82559695              83 Administrative
00000000000001C8 0000000088E4CF71 00                      456 2296696689          0        128        523       2582 log file sync                            ACTIVE   WAITING                    44688489              45 Commit
0000000000000002 0000000000000015 0000000000000002          2         21          2        183          1      20011 control file parallel write              ACTIVE   WAITING                    82559359              83 System I/O
--//可以发现出现log file sync等待事件.

--//session 2,不断按c继续执行.最后session 1,提交ok.
--//session 1:
SCOTT@book> commit ;
Commit complete.

SCOTT@book> select sysdate from dual ;
SYSDATE
-------------------
2019-11-26 08:59:17

--//session 2,不断按c继续执行,最后session 3切换日志ok.
--//session 3:
SYS@book> alter system switch logfile ;
System altered.

--//session 2:
--//按ctrl+c强制中断,退出gdb界面.

SCOTT@book> @ tpt/ash/dash_wait_chains program2||event2 1=1 trunc(sysdate)+8/24+54/1440+14/86400  trunc(sysdate)+8/24+59/1440+17/86400
-- Display ASH Wait Chain Signatures script v0.2 BETA by Tanel Poder ( http://blog.tanelpoder.com )
%This     SECONDS        AAS WAIT_CHAIN
------ ---------- ---------- --------------------------------------------------------------------------
  34%         210         .7 -> (sqlplus) switch logfile command  -> (LGWR) control file parallel write
  34%         210         .7 -> (LGWR) control file parallel write
  23%         140         .5 -> (sqlplus) log file sync  -> (LGWR) control file parallel write
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  10%          60         .2 -> (MMON) enq: CF - contention  -> (LGWR) control file parallel write

--//你可以发现产生log file sync的原因是control file parallel write写太慢.

SCOTT@book> @ spid
       SID    SERIAL# PROCESS                  SERVER    SPID       PID  P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
       128        523 4879                     DEDICATED 4880        33        218 alter system kill session '128,523' immediate;

SCOTT@book> @ tpt/ash/dash_wait_chains program2||event2 session_id=128 trunc(sysdate)+8/24+54/1440+14/86400  trunc(sysdate)+8/24+59/1440+17/86400
-- Display ASH Wait Chain Signatures script v0.2 BETA by Tanel Poder ( http://blog.tanelpoder.com )
%This     SECONDS        AAS WAIT_CHAIN
------ ---------- ---------- -----------------------------------------------------------------
 100%         140         .5 -> (sqlplus) log file sync  -> (LGWR) control file parallel write

3.总结:
--//不要一看到log file sync等待事件就以为是redo写入慢,实际上control file parallel write慢也可能导致该等待事件出现.

最新文章

  1. C++ 一次创建多级目录
  2. git和github使用方式
  3. spring,hibernate,struts的面试笔试题
  4. WCF websocket
  5. Plus One 解答
  6. NetCat,在网络工具中有“瑞士军刀”美誉
  7. 使用rsync命令提高文件传输效率
  8. Swift2.0 函数学习笔记
  9. 注册表操作(VC_Win32)
  10. Egg.js
  11. 网络-02-端口号-linux端口详解大全
  12. Talend 数据转换
  13. 四则运算APP,团队项目之需求
  14. Sublime Text添加插入带当前时间说明
  15. mongodb常用查询
  16. uboot的静默编译、指定编译目录、多核编译
  17. HDU 4336 Card Collector 期望dp+状压
  18. [Node.js] Level 5. Express
  19. ionic学习笔记—常用命令
  20. 图像运动去模糊(Motion Deblurring)代码

热门文章

  1. 机器学习预测时label错位对未来数据做预测
  2. 设置QQ环境变量
  3. 【Java SE】使用Javacv截取视频图片
  4. 一个非常美的FlutterUI组件扩展集:FLUI
  5. Sockit 硬件接口编程——点亮一个LED
  6. 一个简单的示例在spring boot中实现国际化
  7. diff命令的妙用
  8. 【程序人生】一个IT人的立功,立言,立德三不朽
  9. Base64编码原理及应用
  10. .NET Core依赖注入集成Dynamic Proxy