Wednesday, August 18, 2010

Killing the blocking session

Killing the blocking session
===============================

Normally, you should use the KILL USER SESSION menu found in TopSessions.
You can also issue an ALTER SESSION KILL SESSION sid, serial#; in an sqlplus
session.

When on unix or vms,you can kill the unix/vms shadow process directly. Is is not recommended.
When killing the shadow process, please be careful of shared servers in a multi-threaded environment.
e.g.
kill -9 6246   (shadow process on unix)
stop/id= (PROC SPID=SESS SPID on vms running single task) 

To find process information, one can execute this query:

column "ORACLE USER" format a11
column SERIAL# format 9999999
column "OS USER" format a8

    select distinct substr(s.username,1,11) "ORACLE USER", p.pid "PROCESS ID",
       s.sid "SESSION ID", s.serial#, osuser "OS USER", p.spid "PROC SPID",
       s.process "SESS SPID", s.lockwait "LOCK WAIT"
    from v$process p, v$session s, v$access a
    where a.sid=s.sid and
       p.addr=s.paddr and
       s.username != 'SYS'
       and a.sid in (select l.sid from v$lock l
                      where (id1,id2) in
                            (select b.id1, b.id2 from v$lock b where b.id1=l.id1 and
                             b.id2=l.id2 and b.request>0));

ORACLE USER PROCESS ID SESSION ID  SERIAL# OS USER  PROC SPID SESS SPID LOCK WAI
----------- ---------- ---------- -------- -------- --------- --------- --------
SCOTT               17         11     3313 oracle8i 6247      6246      801113A4
SCOTT               20         19     3611 oracle8i 6258      6257

No comments:

Post a Comment

Command to do active duplicate for Oracle Database

1. First login to target server 2. Validate tns connectivity between Source DB and Target DB 3. Prepare and validate space availability 4. S...