Kill oracle session?

Kill oracle session?

Postby ippbx on Thu Aug 21, 2008 2:42 pm

I have an application that connects to an Oracle database and its connection is hung. The program restarted but we are getting record locking errors. Is there anyway to restart or kill the hung session?

ippbx
Newbie
Newbie
 
Posts: 4
Joined: Thu Apr 05, 2007 10:28 am

Re: Kill oracle session?

Postby Darwin on Thu Aug 21, 2008 3:01 pm

Sessions can be killed from within oracle using the ALTER SYSTEM KILL SESSION syntax.

First identify the offending session as follows:

SELECT s.sid,
s.serial#,
s.osuser,
s.program
FROM v$session s;

SID SERIAL# OSUSER PROGRAM
---------- ---------- ------------------------------ ---------------
1 1 SYSTEM ORACLE.EXE
2 1 SYSTEM ORACLE.EXE
3 1 SYSTEM ORACLE.EXE
4 1 SYSTEM ORACLE.EXE
5 1 SYSTEM ORACLE.EXE
6 1 SYSTEM ORACLE.EXE
20 60 SYSTEM DBSNMP.EXE
43 11215 USER1 SQLPLUSW.EXE
33 5337 USER2 SQLPLUSW.EXE

The SID and SERIAL# values of the relevant session can then be substituted into the following statement:

SQL> ALTER SYSTEM KILL SESSION 'sid,serial#';

In some situations the Oracle.exe is not able to kill the session immediately. In these cases the session will be "marked for kill". It will then be killed as soon as possible.

Issuing the ALTER SYSTEM KILL SESSION command is the only safe way to kill an Oracle session. If the marked session persists for some time you may consider killing the process at the operating system level, as explained below. Killing OS processes is dangerous and can lead to instance failures, so do this at your own peril.

It is possible to force the kill by adding the IMMEDIATE keyword:

SQL> ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;

This should prevent you ever needing to use the orakill.exe in Windows, or the kill command in UNIX/Linux.

User avatar
Darwin
Jr. Member
Jr. Member
 
Posts: 93
Joined: Mon Oct 09, 2006 11:16 am
Location: Bradenton, FL


Return to Oracle

Who is online

Users browsing this forum: No registered users and 0 guests

cron