oracle killed會話不釋放


 

一般情況下,在殺一個會話的時候,直接執行alter system kill session ‘sid,serial#’;

Administrator's Guide說,當session是active的時候,alter system kill session 只是將session標識為killed

或者pseudo狀態,並不會釋放session持有的資源,所以我們在執行完alter system kill session 后,看會話還

是一直存在。

捕獲

 

 

這種情況下可以使用 immediate選項,強制立即Kill會話,如下:
SQL> alter system kill session '3964,51752' immediate;

SQL Language Reference 里對Immediate的解釋是:IMMEDIATE Specify IMMEDIATE to instruct Oracle

Database to roll back ongoing transactions, release all session locks, recover the entire session state,

and return control to you immediately.

 

另外我們也可以使用alter system disconnect session

The POST_TRANSACTION setting allows ongoing transactions to complete before the session is disconnected.

If the session has no ongoing transactions, then this clause has the same effect described for as KILL SESSION.

The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without

waiting for ongoing transactions to complete.

  • If you also specify POST_TRANSACTION and the session has ongoing transactions, then the IMMEDIATE keyword is ignored.

  • If you do not specify POST_TRANSACTION, or you specify POST_TRANSACTION but the session has no ongoing transactions,

  • then this clause has the same effect as described for KILL SESSION IMMEDIATE.

  •  

end_session_clauses

 

 

ORACLE建議的DCD解決方法

  1. 修改sqlnet.ora文件,新增expire_time=x(單位是分鍾)
  2. 通過ALTER PROFILE DEFAULT LIMIT IDLE_TIME x; 命令修改,重啟后生效。

 

 

通過OS殺進程終止會話

 

SELECT spid, osuser, s.program, schemaname
FROM gv$process p, gv$session s
WHERE p.addr = s.paddr;
  1. UNIX

kill -9 5745

ps -ef | grep pmon_$ORACLE_SID | awk '{print $2}' | xargs kill –9 #kill 一批會話

 

2. WINDOWS

orakill <instance_name> <spid>

 

如果會話已經在DB里killed,上面的SQL已經查不出spid,可以用下面的SQL查出SPID

select addr, pid, spid
  FROM v$process p
 where addr in (select p.addr
                  from v$process p
                 where pid <> 1
                minus
                select s.paddr from v$session s)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM