Cannot Compile Oracle Function ORA-04021


I was get this error when I alter and compile one function

ORA-04021: timeout occurred while waiting to lock object

First try, I use this query to find what cause this error

SELECT p.spid “Thread”,
s.sid “SID-Top Sessions”,
SUBSTR (s.osuser, 1, 15) “OS User”,
SUBSTR (s.program, 1, 25) “Program Running”,
s.username
FROM v$process p, v$session s
WHERE p.addr = s.paddr
ORDER BY SUBSTR (s.osuser, 1, 15)

Then I use

SELECT * FROM v$access where object = ‘[function_name]’

, the query took lonq execution. So, I use the simple query

SELECT * FROM v$access

then I find and now I can see who is locking the function. Just kill the user and I can compile the function again

alter function [function_name] compile;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: