查詢前100個含有根阻塞程式的Hang Chain程式指令碼
set pages 1000
set lines 120
set heading off
column w_proc format a50 tru
column instance format a20 tru
column inst format a28 tru
column wait_event format a50 tru
set pages 1000
set lines 120
set heading off
column w_proc format a50 tru
column instance format a20 tru
column inst format a28 tru
column p1 format a16 tru
column p2 format a16 tru
column p3 format a15 tru
column seconds format a50 tru
column sincelw format a50 tru
column blocker_proc format a50 tru
column waiters format a50 tru
column chain_signature format a100 wra
column blocker_chain format a100 wra
select * from
(
select
'Current Process: '||osid W_PROC,
'SID: '||i.INSTANCE_NAME INSTANCE,
'INST #: '||wc.INSTANCE INST,
'Blocking Process: '||decode(wc.BLOCKER_OSID,null,'<none>',wc.BLOCKER_OSID)||' from Instance '||wc.BLOCKER_INSTANCE BLOCKER_PROC,
'Number of waiters: '||wc.NUM_WAITERS waiters,
'Final Blocking Process: '||decode(ps.spid,null,'<none>',ps.spid)||' from Instance '||s.FINAL_BLOCKING_INSTANCE FBLOCKER_PROC,
'Program: '||ps.program image,
'Wait Event: '||wc.WAIT_EVENT_TEXT wait_event,
'P1: '||wc.p1 p1,
'P2: '||wc.p2 p2,
'P3: '||wc.p3 p3,
'Seconds in Wait: '||wc.IN_WAIT_SECS Seconds,
'Seconds Since Last Wait: '||wc.TIME_SINCE_LAST_WAIT_SECS sincelw,
'Wait Chain: '||CHAIN_ID||' : '||CHAIN_SIGNATURE chain_signature,
'Blocking Wait Chain: '||decode(wc.BLOCKER_CHAIN_ID,null,'<none>',wc.BLOCKER_CHAIN_ID) blocker_chain
from v$wait_chains wc, gv$instance i,gv$session s,gv$session bs,gv$process ps
where wc.INSTANCE=i.INSTANCE_NUMBER(+)
and (wc.instance=s.inst_id(+) and wc.sid=s.sid(+) and wc.sess_serial#=s.serial#(+))
and (s.FINAL_BLOCKING_INSTANCE=bs.inst_id(+) and s.FINAL_BLOCKING_SESSION=bs.sid(+))
and (bs.inst_id = ps.inst_id(+) and bs.paddr = ps.addr(+))
and (wc.num_waiters > 0 or (wc.blocker_osid is not null and in_wait_secs > 10))
order by wc.CHAIN_ID,NUM_WAITERS desc
)
where rownum < 101;
Current Process: 117931 SID: orcl INST #: 1
Blocking Process: <none> from Instance Number of waiters: 2
Final Blocking Process: <none> from Instance
Program: Wait Event: SQL*Net message from client
P1: 1650815232 P2: 1 P3: 0 Seconds in Wait: 1375
Seconds Since Last Wait:
Wait Chain: 1 : 'SQL*Net message from client'<='enq: TX - row lock contention'
Blocking Wait Chain: <none>
Current Process: 122878 SID: orcl INST #: 1
Blocking Process: 117931 from Instance 1 Number of waiters: 0
Final Blocking Process: 117931 from Instance 1
Program: oracle@bigdata111 (TNS V1-V3) Wait Event: enq: TX - row lock contention
P1: 1415053318 P2: 655366 P3: 908 Seconds in Wait: 695
Seconds Since Last Wait:
Wait Chain: 1 : 'SQL*Net message from client'<='enq: TX - row lock contention'
Blocking Wait Chain: <none>
Current Process: 118052 SID: orcl INST #: 1
Blocking Process: 117931 from Instance 1 Number of waiters: 0
Final Blocking Process: 117931 from Instance 1
Program: oracle@bigdata111 (TNS V1-V3) Wait Event: enq: TX - row lock contention
P1: 1415053318 P2: 655366 P3: 908 Seconds in Wait: 1357
Seconds Since Last Wait:
Wait Chain: 2 : 'SQL*Net message from client'<='enq: TX - row lock contention'
Blocking Wait Chain: 1
程式122878和118052被117931程式阻塞,程式122878和118052都在等待enq: TX - row lock contention等待事件。
等待鏈中的根程式為117931,殺掉該程式將解除Hang等待鏈。
wait_chain_finalblocking.sh
#!/bin/bash
# by ray
# 2017-06-16
#v0.1
. ~/.bash_profile
sqlplus -s /nolog <<-RAY
conn / as sysdba
set pages 1000
set lines 120
set heading off
column w_proc format a50 tru
column instance format a20 tru
column inst format a28 tru
column wait_event format a50 tru
set pages 1000
set lines 120
set heading off
column w_proc format a50 tru
column instance format a20 tru
column inst format a28 tru
column p1 format a16 tru
column p2 format a16 tru
column p3 format a15 tru
column seconds format a50 tru
column sincelw format a50 tru
column blocker_proc format a50 tru
column waiters format a50 tru
column chain_signature format a100 wra
column blocker_chain format a100 wra
select * from
(
select
'Current Process: '||osid W_PROC,
'SID: '||i.INSTANCE_NAME INSTANCE,
'INST #: '||wc.INSTANCE INST,
'Blocking Process: '||decode(wc.BLOCKER_OSID,null,'<none>',wc.BLOCKER_OSID)||' from Instance '||wc.BLOCKER_INSTANCE BLOCKER_PROC,
'Number of waiters: '||wc.NUM_WAITERS waiters,
'Final Blocking Process: '||decode(ps.spid,null,'<none>',ps.spid)||' from Instance '||s.FINAL_BLOCKING_INSTANCE FBLOCKER_PROC,
'Program: '||ps.program image,
'Wait Event: '||wc.WAIT_EVENT_TEXT wait_event,
'P1: '||wc.p1 p1,
'P2: '||wc.p2 p2,
'P3: '||wc.p3 p3,
'Seconds in Wait: '||wc.IN_WAIT_SECS Seconds,
'Seconds Since Last Wait: '||wc.TIME_SINCE_LAST_WAIT_SECS sincelw,
'Wait Chain: '||CHAIN_ID||' : '||CHAIN_SIGNATURE chain_signature,
'Blocking Wait Chain: '||decode(wc.BLOCKER_CHAIN_ID,null,'<none>',wc.BLOCKER_CHAIN_ID) blocker_chain
from v\$wait_chains wc, gv\$instance i,gv\$session s,gv\$session bs,gv\$process ps
where wc.INSTANCE=i.INSTANCE_NUMBER(+)
and (wc.instance=s.inst_id(+) and wc.sid=s.sid(+) and wc.sess_serial#=s.serial#(+))
and (s.FINAL_BLOCKING_INSTANCE=bs.inst_id(+) and s.FINAL_BLOCKING_SESSION=bs.sid(+))
and (bs.inst_id = ps.inst_id(+) and bs.paddr = ps.addr(+))
and (wc.num_waiters > 0 or (wc.blocker_osid is not null and in_wait_secs > 10))
order by wc.CHAIN_ID,NUM_WAITERS desc
)
where rownum < 101;
exit;
RAY
|
注:內容摘錄自:羅敏 <<感悟oracle核心技術>>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28572479/viewspace-2140829/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用Shell指令碼查詢程式對應的程式ID指令碼
- row lock contention 阻塞程式查詢
- library cache lock 阻塞程式查詢
- library cache pin 阻塞程式查詢
- windows根據程式號查詢程式目錄Windows
- 根據程式的ID取得該程式的SQL指令碼SQL指令碼
- 根據欄位名等查詢SAP的表或結構(程式程式碼)
- 查詢有多少JOB正在執行,程式被hang住
- 根據日期來查詢mysql的binlog日誌的指令碼MySql指令碼
- js實現的查詢陣列中含有指定值的數量程式碼例項JS陣列
- oracle會話阻塞查詢指令碼及對應欄位含義Oracle會話指令碼
- 這個實時公交查詢小程式,支援全國 100 個城市
- [指令碼] 查詢wait event的session以及對應的OS程式指令碼AISession
- 一個NOT EXISTS含有OR條件子查詢的優化優化
- 【DBA 指令碼】查詢current open cursor的指令碼指令碼
- MySQL查詢某個欄位含有字母數字的值MySql
- Oracle查詢前100萬條資料Oracle
- mysql like查詢 - 根據多個條件的模糊匹配查詢MySql
- 查詢一個事務程式碼所使用的BADI
- oracle session阻塞查詢OracleSession
- linux下根據埠號查詢對應程式Linux
- 記錄一個簡陋的根據statspack查詢哪段時間事務量最大的指令碼指令碼
- openstack程式碼共享量查詢
- 多階BOM查詢程式碼
- 一個簡單的字串查詢程式字串
- [轉載]ABAP中查詢程式碼的標準程式
- 查詢阻塞與被阻塞SQL語句SQL
- MySQL如何查詢某個欄位含有字母數字的值MySql
- 前後端分離-根據程式碼講解思路後端
- 程式查詢
- 根據作業系統程式號,查詢sql語句作業系統SQL
- 一個改進後的根據STATSPACK來查詢哪段時間內的事務量最大的指令碼指令碼
- Oracle中查詢阻塞與被阻塞SID的方法Oracle
- Oracle阻塞會話查詢Oracle會話
- MySQL查詢阻塞語句MySql
- Oracle阻塞(鎖等待)查詢Oracle
- Shell 指令碼 ,, 根據程式號退出 從而關機指令碼
- 錯誤程式碼中文查詢GetLastError返回程式碼的含義ASTError