?
Solved

Life after ALTER SYSTEM KILL SESSION

Posted on 2003-12-10
5
Medium Priority
?
18,056 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
[X]
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
5 Comments
 
LVL 48

Assisted Solution

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

Accepted Solution

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

0
 
LVL 2

Assisted Solution

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

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

Industry Leaders: 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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses

801 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