(1)A DML operation that is hangingbecause the table which is accessed is currently undergoing changes (ALTERTABLE). This may take quite a long time depending on the size of the table andthe type of the modification (e.g. ALTER TABLE x MODIFY (col1 CHAR(200) on atable with thousands of records)
In this case,V$LOCK will show that the session doing the 'ALTER TABLE' with an exclusive DMLenqueue lock on the table object (LMODE=6, TYPE=TM where ID1 is the OBJECT_IDof the table). The waiting session however does not show up in V$LOCK yet so inan environment with a lot of concurrent sessions the V$LOCK information will beinsufficient to track down the culprit blocking your operation.
(2)The compilation of package willhang on Library Cache Lock and Library Cache Pin if any users are executing aprocedure/function defined in the same package.
LEVEL参数:
10Dump all processes (IGN state)
5Level 4 + Dump all processes involved in wait chains (NLEAF state)
4Level 3 + Dump leaf nodes (blockers) in wait chains(LEAF,LEAF_NW,IGN_DMP state)
3Level 2 + Dump only processes thought to be in a hang (IN_HANG state)
1-2Only HANGANALYZE output, no process dump at all
level 266= SYSTEM STATE (level=10, withshort stacks) = level 10 + short stacks
level 266 在level 10的基础上包含了进程的short stacks信息
systemstat 226级别在9.2.0.6 之前不可用,所以在之前的版本可以使用如下命令:
alter session set max_dump_file_size=unlimited;
alter session set events 'immediate trace name systemstate level 10'
然后使用awk来分析systemdump 的trace:
Oracle 使用ass.awk 工具查看system state dump 说明
http://blog.csdn.net/tianlesoftware/article/details/7237729
这里也可以直接用systemdump 查看所有的进程信息。
2.2 查看X$KGLLK表
The X$KGLLK table (accessibleonly as SYS/INTERNAL) contains all the library object locks (both held &requested) for all sessions and is more complete than the V$LOCK view althoughthe column names don't always reveal their meaning.
--X$KGLLK 表只能被SYS/INTERNAL用户访问,其包含所有library object locks的信息(held和requested)。
KGLLKREQ: This will show you the library cache lock requested by this session(KGLLKREQ > 0)
KGLNAOBJ:contains the first 80 characters of the name of the object.
KGLLKHDL:corresponds with the 'handle address' of the object
select kgllkses saddr, kgllkhdl handle,kgllkmod mod, kglnaobj object
from x$kgllk lock_a
where kgllkmod > 0
andexists (select lock_b.kgllkhdl
from x$kgllk lock_b
where kgllkses = '572ed244'/* blocked session*/
and lock_a.kgllkhdl =lock_b.kgllkhdl
and kgllkreq > 0);
SADDRHANDLE MOD OBJECT
------------------- ------- --------
572eac94 62d064dc3 EMPLOYEES
--查看所有blocked的session:
selectsid, username,terminal, program
from v$session
where saddr in
(select kgllkses
from x$kgllk lock_a
where kgllkreq > 0
andexists (select lock_b.kgllkhdl
from x$kgllk lock_b
where kgllkses = '572eac94'/* blocking session*/
and lock_a.kgllkhdl =lock_b.kgllkhdl
and kgllkreq = 0));
--查看所有持有librarycache pin 或者lock的session 在做什么:
SELECT s.sid, kglpnmod"Mode",kglpnreq "Req", SPID "OS Process"
FROM v$session_wait w,x$kglpn p, v$session s, v$process o
WHERE p.kglpnuse =s.saddr
AND kglpnhdl = w.p1raw
and w.event like'%library cache %'
and s.paddr = o.addr