ORA-04021 timeout occurred while waiting to lock object stringstringstringstringstring
Cause: While waiting to lock a library object, a timeout is occurred.
Action: Retry the operation later.
来自: Oracle, Aaron Wang 01-Aug-01 19:33
主题: Re : alter package compile -> timeout occurred while waiting to lock object
To find out who is blocking you, run the query in another session while you're compiling.
Kill the offending session, and your complilation should go through.
set line 128
SELECT sid, DECODE( block, 0, 'NO', 'YES' ) BLOCKER,
DECODE( request, 0, 'NO', 'YES' ) WAITER, id1, id2, lmode /* 6 is exclusive lock. For others, refer to SV10 */
FROM v$lock
WHERE request > 0 OR block > 0
ORDER BY block DESC
/
To find out what objects is being hold
set line 128
SELECT b.object_name,
decode( a.locked_mode,
0, 'None', /* Mon Lock equivalent */
1, 'Null', /* N */
2, 'Row-S (SS)', /* L */
3, 'Row-X (SX)', /* R */
4, 'Share', /* S */
5, 'S/Row-X (SSX)', /* C */
6, 'Exclusive',
a.locked_mode) Locked_Mode, /* X */
session_id, oracle_username, os_user_name, process
FROM v$LOCKED_OBJECT a, ALL_OBJECTS b
WHERE a.object_id = b.object_id
and a.locked_mode in (3, 5, 6)
and a.session_id=&sid;
The reason the session is marked KILLED is because Oracle only remove the entry from v$session
when you try to use the session again. If this case, your session has already crashed (closed),
there's no way you can use it again. So another way is to remove it from OS level.
If you're running unix, you can use a KILL command to do that.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/45259/viewspace-134848/ ,如需转载,请注明出处,否则将追究法律责任。