Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win



Posted on 2003-12-10
Medium Priority
Last Modified: 2007-12-19
What can stop ALTER SYSTEM KILL SESSION 'n,n' from actually killing a session?
A particular example: A multi-threaded application runs on a separate server against an Oracle 8.1.7 database. The server running the application restarts. When running a query for the current database sessions using v_$session the now dead application's sessions still appear. Issuing a KILL seems to make no difference.

The sessions eventually disappear from v_$session but I am unsure as to whether the DB has tidied these up because it realises they are inactive or because the KILL has marked them as inactive and the DB gets around to tidying them up. In any case why would the database not kill the session immediately as it does other user sessions? Or, is the database killing the sessions immediately and v_$session just isn't the right place to look?

I would appreciate any help.
Question by:IanBlundell
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 48

Assisted Solution

schwertner earned 80 total points
ID: 9912802
Old problem! Nobody knows when the session will be  killed! An old posting here claims that sometimes this can take days.
LVL 23

Accepted Solution

seazodiac earned 100 total points
ID: 9913103
I found this very true too.

Alter system kill session works mostly for sessions from sqlplus but not for external application such as JDBC, ODBC apps.

And I checked this with Oracle metalink, here is what they told me:
It is true that alter system kill session does not actually kill them.
What is always said is server need to rollback all uncommited changes and as it is done by PMON in backgraund it is much slowlier than done by user process itself when explicit rollback statement issued.

If an active session cannot be interrupted (for example, it is performing network I/O or rolling back a transaction), the session cannot be terminated until the operation completes. In this case, the session holds all resources until it is terminated. Additionally, the session that issues the ALTER SYSTEM statement to terminate a session waits up to 60 seconds for the session to be terminated; if the operation that cannot be interrupted continues past one minute, the issuer of the ALTER SYSTEM statement receives a message indicating that the session has been "marked" to be terminated. A session
marked to be terminated is indicated in V$SESSION with a status of "KILLED" and a server that is something other than "PSEUDO."

If the transaction cannot be rolled back by pmon, you may find errors or something indicating what the problem was in the pmon background trace file.

Hope this helps


Assisted Solution

AlbertYou earned 70 total points
ID: 9918541

Hi all,

I have recorded a solution in a PAQ.
You can try to killing the operating system process or thread:

1. Killing sessions in WINDOWS 2000/NT
issue in a DOS command window:
orakill sid thread

where sid    = the Oracle instance to target
        thread = the thread id of the thread to kill
   The thread id should be retrieved from the spid column of a query such as:
         select spid, osuser, s.program from
        v$process p, v$session s where p.addr=s.paddr
 You can find ORAKILL.exe in $ORACLE_HOME\bin

2. Killing sessions in UNIX:

select vs.sid, vs.username, vs.osuser, vs.process fg_pid, vp.spid bg_pid
from v$session vs, v$process vp
where vs.paddr = vp.addr

---- --------------- ---------- --------- ---------
14   QZBHS1          QZBHS1     2924:3744 1948
29   QZBHS1          QZBHS1     3632:3844 15452
51   QZBHS1          QZBHS1     4644:3892 5438

Issued in unix (as the oracle unix user, the user thats owns the database) :

kill -9 1948
kill -9 15452
kill -9 5438

Hope this can help you.


Author Comment

ID: 9920119

Thanks for your responses. In an attempt to be fair handed I am going to spread out the points as follows:

schwertner: 40 points for the most concise answer.
seazodiac: 50 points for an expanded answer with some pointers.
AlbertYou: 35 points for a way to try and kill the errant sessions (although this wasn't requested - it might come in useful).


Expert Comment

ID: 11777800
I have found that the orakill does not always work in windows enviroment.

Sometime the user restart their computer in hopes that it will remove the 'Killed' status.

So when I for example issue:
orakill 28 3124

I get an error saying:
Could not attach to Oracle instance 28: err = 2

And the process still sticks around.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to recover a database from a user managed backup

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question