Oracle9i contains a bug where a PL/SQL client can incorrectly lock an object in the library cache. This is solved in Oracle9i patch 4 and Oracle9iR2. Note that it is not the normal object lock but a library cache lock.
Library cache locks can be found with:
select distinct /*+ all_rows */
h1.sid holding_session,
h1.username, h1.osuser, h1.terminal, h1.program, h1.module, h1.action,
w1.sid waiting_session,
w1.username waiting_user, w1.osuser, w1.terminal, w1.program, w1.module, w1.action,
w.kgllktype lock_or_pin,
od.to_name,
decode(h.kgllkmod, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive',
'Unknown') mode_held,
decode(w.kgllkreq, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive',
'Unknown') mode_requested
from dba_kgllock w, dba_kgllock h, v$session w1,
v$session h1, v$object_dependency od
where (((h.kgllkmod != 0) and (h.kgllkmod != 1)
and ((h.kgllkreq = 0) or (h.kgllkreq = 1)))
and (((w.kgllkmod = 0) or (w.kgllkmod= 1))
and ((w.kgllkreq != 0) and (w.kgllkreq != 1))))
and w.kgllktype = h.kgllktype
and w.kgllkhdl = h.kgllkhdl
and w.kgllkuse = w1.saddr
and h.kgllkuse = h1.saddr
and od.to_address= w.kgllkhdl
Bo Pedersen