SESSION 34 执行存储过程: SESSION 43 编译存储过程: SESSION 25 删除存储过程: 1.查询查看library cache lock等待事件的相关会话 SQL> select sid, P1RAW,P1TEXT ,event from v$session_wait where event not like '%message%'; SID P1RAW P1TEXT EVENT ---------- ---------------- ---------------------------------------------------------------- ---------------------------------------------------------------- 2 000000000000006F duration pmon timer 3 00 VKTM Logical Idle Wait 5 0000000000000005 component DIAG idle wait 8 0000000000000005 component DIAG idle wait 10 00000000000006F0 requests db file async I/O submit 13 000000000000012C sleep time smon timer 18 00 Streams AQ: qmn coordinator idle wait 25 000000002BF0897C handle address library cache lock 26 0000000000000001 Type Streams AQ: qmn slave idle wait 28 0000000000000001 Slave ID Space Manager: slave idle wait 31 0000000000000004 file# db file sequential read SID P1RAW P1TEXT EVENT ---------- ---------------- ---------------------------------------------------------------- ---------------------------------------------------------------- 32 00 Streams AQ: waiting for time management or cleanup tasks 34 0000000000000004 file# db file sequential read 43 000000002BF0897C handle address library cache pin SQL> select saddr,sid,username,event,p1raw from v$session where event='library cache lock'; SADDR SID USERNAME EVENT P1RAW -------- ---------- ------------------------------ ---------------------------------------------------------------- ---------------- 35FEE7F0 25 TEST library cache lock 000000002BF0897C 2.查询持有library cache lock的会话以及lock住的对象 SQL> select user_name,kglnaobj "Owner",kgllkses saddr,kgllkreq req,kgllkmod mod,kglnaobj object from x$kgllk lock_a where kgllkmod > 0 and exists (select lock_b.kgllkhdl from x$kgllk lock_b where kgllkses = '35FEE7F0' /* blocked session */ and lock_a.kgllkhdl = lock_b.kgllkhdl and kgllkreq > 0); 2 3 4 5 6 7 USER_NAME Owner SADDR REQ MOD OBJECT ------------------------------ ------------------------------------------------------------ -------- ---------- ---------- --------------------------------- --------------------------- TEST TEST_PRC 35FD6A24 0 1 TEST_PRC TEST TEST_PRC 35FBEC58 0 3 TEST_PRC 这里出现了两行结果,不过从mod列可以判断35FD6A24这个会话持有的lock模式为1(如果没记错的话数字1表示null),所以正在阻塞25会话的是会话地址为35FBEC58的会话。 你也可以通过以下sql做进一步验证 SQL> select sid,saddr,event,q.sql_text from v$session s,v$sql q where saddr in ('35FD6A24','35FBEC58') and s.sql_id=q.sql_id; 2 SID SADDR EVENT SQL_TEXT ---------- -------- -------------------- -------------------- 34 35FD6A24 db file sequential r INSERT INTO TEST1 SE ead LECT * FROM TEST1 43 35FBEC58 library cache pin alter procedure tes t_prc compile 从输出结果发现会话地址为35FBEC58 的会话正在编译TEST_PRC,所以该会话持有的lock模式肯定会x,而会话25正是被它所阻塞。