Solved

Life after ALTER SYSTEM KILL SESSION

Posted on 2003-12-10
5
18,036 Views
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.
0
Comment
Question by:IanBlundell
5 Comments
 
LVL 48

Assisted Solution

by:schwertner
schwertner earned 40 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.
0
 
LVL 23

Accepted Solution

by:
seazodiac earned 50 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

0
 
LVL 2

Assisted Solution

by:AlbertYou
AlbertYou earned 35 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

SID  USERNAME        OSUSER     FG_PID    BG_PID
---- --------------- ---------- --------- ---------
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.

Albert.
0
 
LVL 2

Author Comment

by:IanBlundell
ID: 9920119
Experts

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).

0
 

Expert Comment

by:jim_1234567890
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.



0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Web Service from a stored procdure oracle 10 58
su - oracle could not open session 6 95
exp/imp 25 85
Character matching different date formats for dates between 6 59
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

840 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