V$SESSION中的P1, P2,P3定义:
P1: 游标的hash值
P2: 头两个字节表示holding Mutex SID, 后面两个字节通常为0
P3: Mutex where an internal code locator 或 with mutex sleeps
通过v$mutex_sleep可以看到mutex信息
select * from v$mutex_sleep
MUTEX_TYPE LOCATION SLEEPS WAIT_TIME
-------------------------------- ---------------------------------------- ---------- ----------
Cursor Parent kksfbc [KKSPRTLOC2] 42 49
.......................................
Cursor Pin kksSetBindType [KKSCHLPIN3] 20 378277
Cursor Pin kkslce [KKSCHLPIN2] 1819288987 3378316655
从以上视图中发现一个mutex_type cursor pin有严重的sleeps和等待。
select sid, p2raw from v$session where event='cursor: pin S wait on X'
发现所有的sid 的p2raw值相同,通过截取p2raw头两位,转化成十进制,获得holding mutext的SID,然后找出对应的进程将其kill。
在查看holding SID与blocked SID关系的时候,需要用system dump:
alter session set events 'immediate trace name systemstate level 266';
等待几分钟
alter session set events 'immediate trace name systemstate level 266';
查看trace文件,具体呈现如下:
holding 进程: Process 33
KGX Atomic Operation Log c00000047d792a58
Mutex c000000472849030(450, 0) idn 9d25e55e oper EXCL
Cursor Pin uid 450 efd 0 whr 1 slp 0
........................................
name=update b_m_tdm_elec_xmd Set chanl_cust_no = :a0,date_id=:a1 where pro_id=:a and tlr_id=:b and date_id=:c and acct_no=:d
..............................................
Blocked 进程: process 26
waiting for 'cursor: pin S wait on X' blocking sess=0x0000000000000000 seq=32649 wait_time=0 seconds
since wait started=0 idn=9d25e55e, value=1c200000000, where|sleeps=50106dcec
KGX Atomic Operation Log c00000047d28bc08
Mutex c000000472849030(450, 0) idn 9d25e55e oper GET_SHRD
Cursor Pin uid 568 efd 0 whr 5 slp 49205
......................................
name=update b_m_tdm_elec_xmd Set chanl_cust_no = :a0,date_id=:a1 where pro_id=:a and tlr_id=:b and date_id=:c and acct_no=:d
从dump文件可以看出, holding 进程执行update语句,获取Mutex 为独享模式(oper EXCL)。而blodked 进程执行相同的update语句,想获取共享模式(oper GET_SHRD),发生等待,等待的SID=450。
怀疑可能ORACLE的bug,需要以下测试看是否该问题能消除:
1、将内存自动管理(AMM)关闭;
2、设置_kks_use_mutex_pin=false
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/354732/viewspace-604483/,如需转载,请注明出处,否则将追究法律责任。