Daniel, May 30, 2002 - 11:13 am UTC
I also hit this problem several times. My method is first kill the session, if the session is only marked 'KILLED' and doesn't go away, I'll logon to the UNIX ( assuming oracle resides on UNIX ) as DBA to kill the session's dedicated sever process. The lock will be released at once. It seems Tom doesn't recommend this method, I don't know if there is any potential damage to data integrity. Thanks for clarify
Locks not cleared after killing session
Anil, April 10, 2003 - 10:03 pm UTC
I am working in a datawarehouse environment which is on oracle 8.1.7 and os is windows 2000 advanced server.
Our daily data loading takes around 4 hours but this time it took more than 28 hours and it is still not over. So i decided to kill the session. After killing the session the locks are still there.
Can u suggest something to get out of this problem. Should i wait for locks to get cleared on its own. At present the locks are on 37 tables. I had already waited for more than 14 hours but lock is not cleared on even a single table. Is there anything that i can do to clear the locks. I am having dba privileges
Regards,
Anil
April 11, 2003 - 8:22 am UTC
if it took 28 hours to get there -- it might take 28 hours or more to GET BACK.
You are rolling back. Until you roll back -- locks.
Use v$transaction and look at used_ublk to see how fast it is rolling back and how far its got to go.
what you NEED TO DO immediately, while waiting, is get your load code and fill it FULL of calls to dbms_application_info set session longops -- so you can monitor in v$session_longops where you are and how far you have to go so you do not get tempted to kill things again.
A little instrumentation goes a long long long way (and it gives you something to watch)
Look at bug #1785969 on metalink
Chuck Jolley, April 11, 2003 - 10:07 am UTC
We had this problem on an 8.1.7 database pair for updates over a DB Link.
It would hang and NEVER return.
Look at bug #1785969.
We never manualy mess with locks so we had to bounce both DBs to kill the locks when it happened.
We have rewritten the app to use separate connections for the local query and remote update.
Chuck
April 13, 2003 - 7:09 pm UTC
doesn't seem to apply a bit in this case. totally different scenarios.
locks not getting released
jasdeep, March 28, 2004 - 6:17 am UTC
I also hit this problem several times. My method is first kill the session, if
the session is only marked 'KILLED' and doesn't go away.
sometimes it takes 4 hours and get killed whilw othrs are killed fast. Does it show pmon is not releasing resources properly.
thanks in advance
March 28, 2004 - 9:16 am UTC
pmon does not release the resources.
the SESSION does.
if it took a long time to get to the point where you killed it, it'll take a long time to get back to the point where it began (eg: killing an update that has been running for 30 seconds will take slightly less time to release all resources than will killing an update that has been running for 6 hours. "rollback" takes "time")
thanks but
jasdeep, March 28, 2004 - 10:01 am UTC
hi tom,
when we go through the application server which shows that user has logged out.
and still locks are there by that username and even when user has disconnected the session and is not on duty.
in this case can pmon will not release the rsources occupied the user.
March 28, 2004 - 5:02 pm UTC
that is a bug in your application, nothing to do with Oracle at all.
You are using a connection pool.
You are not committing your transactions.
That is the only thing that could be happening here.
You have a bug in your code.
locks
A reader, May 02, 2004 - 12:24 am UTC
hi tom
we have a problem that even after
issuing the command
alter system kill session '#sid,#serial#'
locks r not geeting released and cpu usage gets to 100%
May 02, 2004 - 10:09 am UTC
you have another issue, your keyboard is failing -- it appears to be dropping very relevant letters for communicating to people -- the vowels!
An alter system kill session, applied to a session that was in the middle of a long running transaction, it itself going to "take a while" as it has to now UNDO whatever it had been doing for a potentionally long period of time. (you might want to re-read the answer above, i just paraphrased the entire thing right here again)
query v$transaction and monitor used_ublk
USED_UBLK not changed for a long time
Igor, June 30, 2004 - 11:57 am UTC
Hi Tom,
The user application stuck in middle of updating data, so i had to terminate application and "kill session", but after 3 hours session is still marked "killed" and locks are not released (original transaction run less then 30 min). What afraids me most is that for last 3 hours field USED_UBLK in V$TRANSACTION stays at same level. What can i do in such situation?
Igor
PS. I running 8.1.7 on linux
June 30, 2004 - 1:12 pm UTC
step 1 would be to contact support -- they may have something to say.
can you identify the process in the OS that was associated with that session, killing it might be the only thing (short of a restart) if it is truly stuck.
Functions getting locked (strange)
Reader, November 11, 2004 - 11:23 am UTC
Tom,
This was something i had encountered long back. Never knew the answer. Sorry...cannot reproduce - no database access for me now.
It so happened many times when i try to recompile a function/procedure it hangs indefinitely and then i kill all sessions (inactive) that may seem to have queried/used the function and then it recompiles in a flash.
My qn is -
1. If a function is used in a query in some session, would that prevent the same function from being modified by another session?
2. From which V$ table can i get the information as to why the function recompilation is taking time and which all sessions are using the function.
Thanks a zillion
November 11, 2004 - 11:28 am UTC
1) yes, you cannot replace the code of something that is actually *running*
2) this is a short excerpt from "Expert One on One Oracle"
...
A view that is invaluable for looking at this information is the DBA_DDL_LOCKS view. There is no V$ view we can look at. This view is built on the more mysterious X$ tables and by default, it will not be installed in your database. You can install this and other locking views by running the CATBLOCK.SQL script found in the directory $ORACLE_HOME/rdbms/admin. This script must be executed as the user SYS in order to succeed. Once you have executed this script, you can run a query against the view. For example in a single user database I see:
tkyte@TKYTE816> select * from dba_ddl_locks;
session mode mode
id OWNER NAME TYPE held reqe
------- ------ ------------------------------ -------------------- ---- ----
8 SYS DBMS_APPLICATION_INFO Body Null None
8 SYS DBMS_APPLICATION_INFO Table/Procedure/Type Null None
8 SYS DBMS_OUTPUT Table/Procedure/Type Null None
8 SYS DBMS_OUTPUT Body Null None
8 TKYTE TKYTE 18 Null None
8 SYS DATABASE 18 Null None
6 rows selected.
These are all of the objects my session is 'locking'. I have breakable parse locks on a couple of the DBMS_* packages. These are a side effect of SQL*Plus; it calls DBMS_APPLICATION_INFO, for example. I may see more than one copy of various objects here - this is normal, and just means I have more than one thing I'm using in the shared pool that references these objects. It is interesting to note that in the view, the OWNER column is not the owner of the lock, rather it is the owner of the object being locked. This is why you see many rows with SYS, but they all belong to my session - SYS owns those packages. The other interesting thing to note is the TYPE 18 rows. These are rows that make it not possible to drop that user. If I attempted to drop TKYTE, the DROP would fail attempting to get a lock on the user TKYTE in exclusive mode.
.............
Thank You very much
Reader, November 11, 2004 - 12:12 pm UTC
What causes dependeny locks?
Robert, December 16, 2004 - 10:30 am UTC
Tom,
What are the circumstances in which a dependency is actually LOCKED?
I have seen two different behaviours to this...
Please consider the following...
FACT: procedure A contains a call to procedure B.
FACT: procedure A is running.
FACT: try to recompile procedure B.
At different times I have seen both the following occurrences...
(1) procedure B is locked (can't compile)
(2) procedure B is NOT locked (can compile... and this later caused an error in procedure A).
What are the exact circumstances that cause dependent objects to actually be LOCKED? ... why is procedure B locked sometimes and NOT locked at other times?
Thanks,
Robert.
December 16, 2004 - 10:31 am UTC
was the error "package state discarded" and we are really dicussing packages?
The package was locked...
Robert, December 16, 2004 - 10:52 am UTC
Tom,
The situation here is partily anectodal, and partly from what happened to a job last night.
(anecdotal...but true) I have seen cases where you couldn't recompile a dependent object (e.g. package body) because it was locked by the package calling it... you get a 'timeout' error.
Then, last night we had a job error out with an ORA-600 error, which according to metalink occurred due to recompiling an object which is a dependency of a long running job. Xref'ing dba_dependencies and dba_objects.last_ddl_time we saw that indeed a particular package had been recompiled while the package in which it is referenced was running.
My question is, if the running package (proc A) was referencing (proc B).... why wasn't proc B locked? ... why were we able to recompile it?
Thanks,
Robert
December 16, 2004 - 11:38 am UTC
ora-600 = internal error, isn't supposed to happen, all bets off (eg: a bug)
Documented bug
Robert, December 16, 2004 - 11:55 am UTC
Tom,
2 quick final point/questions, please....
(1). This is a documented bug...
Note: 39616.1 Subject: ORA-600 [17069] "Failed to pin a library cache object after 50 attempts" ... Does that change your answer at all?
(2). Then do I understand correctly...:
IF PROC A contains a reference to PROC B,
THEN (because of the how Oracle is designed) PROC B should be LOCKED (unable to re-compile) the entire time PROC A is running ? correct?
... in other words, the very fact that we were ABLE to compile PROC B while PROC A was running is BY DEFINITION a bug... correct?
Thanks!
Robert
December 16, 2004 - 12:04 pm UTC
ora-600 >>> internal error -->>>>> bug ---->>>>>>> all bets off, something that wasn't supposed to happen, did.
Then we can take it to the bank?!
Robert, December 16, 2004 - 12:13 pm UTC
Tom,
Is the following reasoning correct...
FACT: PROC_A references PROC_B
CONCLUSION: We should NEVER be able to re-compile PROC_B while PROC_A is running.
CORROLARY TO CONCLUSION: If in some situation we ARE ABLE to re-compile PROC_B while PROC_A is running, then this is IPSO FACTO a BUG ?
Are the two conclusions correct, sir?
Thanks,
Robert.
December 16, 2004 - 1:31 pm UTC
fact: proc_a references proc_b
false conclusion: We should NEVER be able to re-compile PROC_B while PROC_A is
running.
proof:
--------------------- test.sql ----------------------------
@testb
create or replace package demo_pkg_a
as
procedure p;
end;
/
create or replace package body demo_pkg_a
as
procedure p
is
begin
dbms_lock.sleep(30);
demo_pkg_b.p;
end;
end;
/
exec demo_pkg_a.p
--------------------------- testb.sql ---------------
create or replace package demo_pkg_b
as
procedure p;
end;
/
create or replace package body demo_pkg_b
as
g_global number;
procedure p
is
begin
g_global := nvl(g_global,0)+1;
dbms_output.put_line( 'hello ' || g_global );
end;
end;
/
--------------------------------------------------------
run test.sql, in session two immediately run testb.sql, session 1 will return with:
ops$tkyte@ORA9IR2> exec demo_pkg_a.p
BEGIN demo_pkg_a.p; END;
*
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04065: not executed, altered or dropped stored procedure
"OPS$TKYTE.DEMO_PKG_B"
ORA-06508: PL/SQL: could not find program unit being called
ORA-06512: at "OPS$TKYTE.DEMO_PKG_A", line 7
ORA-06512: at line 1
<b>what is ipso facto correcto here is you got an ora-600, and ora-600 = "a bug"</b>
Good Analogy?
Bob B, December 16, 2004 - 1:27 pm UTC
I don't know how many times I've seen on this site where someone says "I killed this session after it had been running for x hours and it still had locks." I think a good analogy for how killing a session works is cooking.
Let's say you had a recipe (i.e. what your session is doing):
You put some cheese in a pot, add some salt, boil some water out, whatever you want. If someone wanted to borrow your pot (i.e. someone tries to lock a resource you've locked), you'd tell them to wait until you are done.
Let's say you're in the middle of making a lasagna and you see smoke and decide to abort the thing (i.e. kill the session). Now before someone can use the pot, you've got to put it back to the way it was (rollback), otherwise, it'll be dirty (no data integrity). Sometimes it will take less time to clean the pot than it did to make it dirty. Sometimes it will take more time to clean the pot than it did to make it dirty.
Same is true of sessions, if it takes 20 minutes to get where its got, it'll probably take 20 minutes to put it back, but it could take more time, it could take less time. All a matter of making sure everything is clean before releasing the locks
December 16, 2004 - 1:40 pm UTC
works for me
You do what?
Angus McTavish, March 28, 2006 - 5:52 am UTC
"You put some cheese in a pot, add some salt, boil some water out, whatever you want. "
I don't think I'll be going to Bob's house for dinner...
v$locked_object
Chaman, April 01, 2008 - 9:24 am UTC
Tom,
Even though the V$LOCKED_OBJECT shows no entry for a procedure but when I try to compile it says object locked.
When I shutdown and re-started it worked.
Why was V$LOCKED_OBJECT not showing ?
April 01, 2008 - 9:49 am UTC
A reader, April 02, 2008 - 8:24 am UTC
Tom,
It says 'The locks are imposed to ensure that they are not aged out of the library cache while they are required for SQL'.
Does this mean the object is locked ? What type of lock is this ?
Thanks
April 02, 2008 - 9:00 am UTC
it means "something is running that needs this" - meaning typically "someone is running the code"
you cannot recompile a procedure that someone is using.
Dynamic SQL reference
Nico, April 02, 2008 - 11:46 am UTC
Hello,
While aggreeing totally in Tom's "We should NEVER be able to re-compile PROC_B while PROC_A is running.", I however think about a case where it could happen :
If proc A references proc B using dynamic sql !
Maybe, that's what happened to Robert from Menphis...
April 02, 2008 - 12:06 pm UTC
would not matter - you still will not be able to recompile proc_b
Good Explanation..Need further informatin please.
Bhushan, April 03, 2008 - 2:57 am UTC
Hi Tom,
Went through the whole page of explanation, appreciate the hard work you put in.however i noticed one exception to what you have said above.
I tried the following pieces of code.
CREATE OR REPLACE PROCEDURE test_child AS
test_date DATE;
BEGIN
SELECT SYSDATE INTO test_date FROM dual;
--dbms_output.put_line(test_date);
END test_child;
CREATE OR REPLACE PROCEDURE test_parent AS
parent_date DATE;
proc_call VARCHAR2(200):= 'test_child';
BEGIN
--test_child;
FOR x IN 1..100 LOOP
FOR i IN (SELECT rownum FROM all_objects) LOOP
SELECT SYSDATE INTO parent_date FROM dual;
END LOOP;
END LOOP;
--EXECUTE IMMEDIATE 'begin test_child; end;';
test_child;
--SELECT SYSDATE INTO test_date FROM dual;
END test_parent;
now when test_parent is executing if i try to compile test_child, as you mentioned i get the package out of state error however when the test_parent is changed to
CREATE OR REPLACE PROCEDURE test_parent AS
parent_date DATE;
proc_call VARCHAR2(200):= 'test_child';
BEGIN
--test_child;
FOR x IN 1..100 LOOP
FOR i IN (SELECT rownum FROM all_objects) LOOP
SELECT SYSDATE INTO parent_date FROM dual;
END LOOP;
END LOOP;
EXECUTE IMMEDIATE 'begin test_child; end;';
--test_child;
--SELECT SYSDATE INTO test_date FROM dual;
END test_parent;
and then execute the procedure and try to re-compile test_child ..no error at all it executes just fine..
whereas i see your statement:
in the last review no matter how the procedure is reffered it should not allow you to compile or give you the error in the parent procedure referring it.
Did i understand your statement right?
Regards,
Bhushan
April 03, 2008 - 7:57 pm UTC
if you try to compile it WHILE running it (make test_child take a long time), you cannot.
Kindly Confirm.
Bhushan, April 03, 2008 - 8:26 pm UTC
PLease confirm the following.
------------
when called normally (NOT using execute immediate)
Test_parent is running in the loop, we try to re-compile test_child we cannot we get package out of state error.
----------
when called using a dynamic SQL
We can still re-compile test_child if the calling statement has not been reached yet?
I hope i am clear in what i want to convey.
Kind Regards,
Bhushan Salgar
P.S: You impress me in the turn around time you have to reply to the queries considering your busy schedule and your position.May be if you put in the logic of multitasking or prioratizing in Oracle you have in your daily life, it can reach new heights ;) of-course unless there is some one doing this job for you :D (Just Kidding)
Cheers!!!
Tkyte
April 03, 2008 - 9:33 pm UTC
#2 would be "if the calling statement is not currently CALLING IT"
as for the last paragraph - it can be hours or days before I respond, it can be seconds before I respond.
As with every question about Oracle - the only answer to "how fast do you respond" is...........
it depends...
v$acess and v$locked_object
aarti, June 08, 2008 - 10:34 pm UTC
Tom,
If both v$acess and v$locked_object views have information of objects which currently in use (or locked) then why there are 2 different views? Is there any situations where a entry will be present in one of the view and not in other?
We have a stored procedure which gets hanged (because of the logical error in the stored procedure) but i have seen there's no entry in v$locked_object but we are not able to compile the stored procedure because it's been locked. But there's an entry in v$access view.
A reader, May 22, 2012 - 10:28 pm UTC
session shown killed but table lock not released
A reader, March 25, 2013 - 5:40 am UTC
This is the first time I am posting. I follow your posts almost daily for some or the other issue. Thanks a ton for doing such a tremendous job.
Ok, I know that this thread started many years ago but is still active :). I am on Oracle 11g R1, 2 node RAC on AIX OS. My issue is that there is a session which is killed (not marked killed but is actually killed) but still this session has acquired a lock on a table. In gv$transaction, USED_UBLOCK corresponding to this session's address is equal to 1 for last 2-3 hours and is not changing at all. Such a situation occurs almost in every 2-3 days in our environment. The people in ETL team load data in some or the other table using mappings.
Though you may have more valuable inputs, I want you to answer these questions too:
1. Is there something that I should look into ETL mappings? I have seen that ETL team uses commit frequency of 1000 rows for committing data. If anything goes wrong, they truncate the entire target table and run the mapping again.
2. Have you seen anyone reporting such a bug in Oracle 11g R1 on AIX OS?
3. Should I look into some other dynamic performance views to determine whether there is still rollback running?
March 25, 2013 - 2:42 pm UTC
what is it marked as? what is its status in v$session
how do you get "not marked killed but is actually killed"??? what got you into that state?
what or how are you "killing" this?
session shown killed but table lock not released
Akhil Mahajan, March 25, 2013 - 10:41 am UTC
This is the first time I am posting. I follow your posts almost daily for some or the other issue.
Thanks a ton for doing such a tremendous job.
Ok, I know that this thread started many years ago but is still active :). I am on Oracle 11g R1, 2
node RAC on AIX OS. My issue is that there is a session which is killed (not marked killed but is
actually killed) but still this session has acquired a lock on a table. In gv$transaction,
USED_UBLOCK corresponding to this session's address is equal to 1 for last 2-3 hours and is not
changing at all. Such a situation occurs almost in every 2-3 days in our environment. The people in
ETL team load data in some or the other table using mappings.
Though you may have more valuable inputs, I want you to answer these questions too:
1. Is there something that I should look into ETL mappings? I have seen that ETL team uses commit
frequency of 1000 rows for committing data. If anything goes wrong, they truncate the entire target
table and run the mapping again.
2. Have you seen anyone reporting such a bug in Oracle 11g R1 on AIX OS?
3. Should I look into some other dynamic performance views to determine whether there is still
rollback running?
March 27, 2013 - 2:32 pm UTC
see above
session shown killed but table lock not released
A reader, March 26, 2013 - 6:39 am UTC
what is it marked as? what is its status in v$session?
Status is KILLED in v$session.
how do you get "not marked killed but is actually killed"??? what got you into that state?
V$session shows process status as KILLED or MARKED FOR KILL. It showed me KILLED for this session. I am emphasizing that the session is KILLED and not MARKED FOR KILL because I understand that a session MARKED FOR KILL will do rollback before it is is actually killed. But a session that is KILLED should ideally release any lock held by it.
what or how are you "killing" this?
Using KILL SESSIONS -> IMMEDIATE option in TOAD.
It is shown KILLED but the lock on table was not released. I then tried to kill the process at OS level by determining its SPID, but the process could also not be found at OS level!
Today, when I queried v$locked_object, I found that the lock was released. Even now when the lock is released, the session is still shown as KILLED in v$session and the process id i.e. SPID is shown in v$process. Before coming to this project, I never saw KILLED sessions in v$session!
Any comments?
March 27, 2013 - 3:04 pm UTC
show me how you ascertained it was blocking others with a lock.
a session marked as killed will have an OS process, it will have a session, but all of its resources should be released. It OS process stays there so that when the client that was associated with this session tries a database operation, we can cleanly return ora-28, your session was killed. then and only then will the session totally go away.