Search code examples
oracle-databasesessionkilldatabase-administration

Removing Oracle killed session


I killed a session

ALTER SYSTEM KILL SESSION '123,456' IMMEDIATE;

But it remains in v$session for 5 days, although an attached process is absent in v$processes.

SELECT
    s.username,
    s.osuser,
    s.sid,
    s.serial#,
    p.spid
  FROM v$session s, v$process p
 WHERE s.sid = '123'
   AND p.addr (+)= s.paddr;

I've also checked all Linux processes related to Oracle and found no zombies: all present processes are consistent to alive sessions.

EDIT: This happens not for all the killed sessions. It seems that PMON is active, because the most of the killed sessions are cleaned from the list in a reasonable time (often it takes a second).

What can be done to eliminate long-playing killed session from the list?


Solution

  • These should be cleaned up by PMON automatically, but sometimes you need to 'wake it up' in the case of stuck processes.

    To wake up PMON, first obtain the PID using

    SELECT pid FROM v$process
    WHERE addr = 
    (
        SELECT paddr FROM v$bgprocess
        WHERE name = 'PMON'
    );
    

    If the PID is 6 then send a wakeup call using:

    ORADEBUG WAKEUP 6

    and you might have to repeat that command a few times until the runaway session is cleared.