[20191126]探究等待事件的本源2.txt
[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慢也可能導致該等待事件出現.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2665756/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20191125]探究等待事件的本源.txt事件
- [20191127]探究等待事件的本源4.txt事件
- [20220531]inactive session等待事件2.txtSession事件
- [20211031]18c row cache mutext等待事件探究.txtMutex事件
- [20240827]分析為什麼出現library cache lock等待事件2.txt事件
- Solidity事件,等待事件Solid事件
- [20220322]探究oracle sequence 2.txtOracle
- [20200217]使用snapper探究DBMS_SHARED_POOL.MARKHOT標識熱物件的等待事件.txtAPP物件事件
- 【TUNE_ORACLE】等待事件之等待事件類別Oracle事件
- [20191119]探究ipcs命令輸出2.txt
- Selenium等待事件Waits事件AI
- read by other session等待事件Session事件
- log file sync等待事件事件
- ORACLE 常見等待事件Oracle事件
- latch等待事件彙總事件
- Latch free等待事件(轉)事件
- gc cr request等待事件GC事件
- 【等待事件】library cache pin事件
- 【等待事件】log file sync事件
- [20181227]簡單探究cluster table(補充)2.txt
- 【TUNE_ORACLE】等待事件之日誌等待“log file sync”Oracle事件
- 【TUNE_ORACLE】等待事件之IO等待“read by other session”Oracle事件Session
- 【TUNE_ORACLE】等待事件之IO等待“direct path read”Oracle事件
- 【TUNE_ORACLE】等待事件之IO等待“direct path write”Oracle事件
- Latch free等待事件四(轉)事件
- Latch free等待事件三(轉)事件
- db file scattered read等待事件事件
- db file sequential read等待事件事件
- latch:library cache lock等待事件事件
- Oracle常見UNDO等待事件Oracle事件
- Latch free等待事件二(轉)事件
- LightDB/PostgreSQL等待事件 Lock transactionidSQL事件
- openGauss/MOGDB與PG等待事件事件
- Cell smart table scan等待事件事件
- read by other session 等待事件分析Session事件
- 【等待事件】db file sequential read事件
- 【等待事件】db file scattered read事件
- 【等待事件】virtual circuit next request事件UI