ORA-04021: timeout occurred while waiting to lock object
OracleWhat does it mean?
A timeout occurred while waiting to acquire a library cache lock/pin on an object (package, procedure, type, etc.). Usually occurs when trying to compile or alter a PL/SQL object while it is being executed or locked by another session.
Why does it happen?
The object to be altered/compiled is actively executing in another session or is locked by another DDL, so the exclusive library cache lock cannot be acquired. A long-running procedure call or a hung session may be holding the lock.
How to fix it
Find the session locking the object: SELECT * FROM dba_kgllock WHERE kgllkhdl IN (SELECT p1raw FROM v$session WHERE event LIKE 'library cache%'); or identify the session using the object with v$access and v$session. Retry the DDL/compile in a maintenance window with low workload. If needed, terminate the session safely. Briefly stopping the application makes acquiring the lock easier.
More from this engine
- ORA-29913error in executing ODCIEXTTABLEOPEN callout
- ORA-19804cannot reclaim N bytes disk space from M bytes limit
- ORA-00494enqueue held for too long by 'inst N, osid M'
- ORA-04061existing state of package/procedure has been invalidated
- ORA-01466unable to read data - table definition has changed
- ORA-08176consistent read failure; rollback data not available
- ORA-00020maximum number of processes (N) exceeded