Oracle Database / Operations & Incident Response
ORA-04021: investigate an object lock timeout during compilation or DDL
A library or object lock timeout can occur when code or metadata is in use. Capture the object name and active workload at the failure time.
Environment and inputs: Oracle Database 19c baseline · SQL*Plus-compatible SQL unless RMAN, DGMGRL, ADRCI or a host shell is specified. Check release, patch level, edition and container first.
Start with this diagnostic
Run each example in the tool named in the guide: SQL, RMAN, DGMGRL or the host command shell. Replace example names with approved values. To query DBA and V$ views, use authorized catalog access in the correct database container. Do not add broad permissions just to run an example.
SELECT session_id, owner, name, type, mode_held, mode_requested FROM dba_ddl_locks WHERE owner = 'APP_OWNER';
What the results mean
The view provides DDL lock context, but some library-cache relationships need further diagnostics. A completed timeout may leave no current waiter.
Fix the cause and check again
Correlate compilation, deployment and long-running calls, then coordinate a safe maintenance window or targeted application drain.
Before you make a change
Do not repeatedly recompile the schema or kill every session using the package.