ORACLE中的KILLED SESSION

在Oracle中终止会话
alter system kill session 'sid,serial#';
在用此命令终止会话后,其状态为killed,资源并没有回收.
在被使用kill终止的进程paddr发生了变化,不能通过v$session和v$process视图的关联来找到spid。参考:http://www.eygle.com/faq/Kill_Session.htm

在最近的一个案例中,有一个进程dllhost.exe,是由于COM+调用时未能中断,
利用alter system kill session 'sid,serial#',其状态为KILLED,

SQL> col program for a20
SQL> select sid,serial#,program,status from v$session  where program ='dllhost.e
xe' and status = 'INACTIVE';

       SID    SERIAL# PROGRAM              STATUS
---------- ---------- -------------------- --------
        24        469 dllhost.exe          INACTIVE
        37        726 dllhost.exe          INACTIVE
        44       1098 dllhost.exe          INACTIVE
        56        526 dllhost.exe          INACTIVE
        61        476 dllhost.exe          INACTIVE
        79        294 dllhost.exe          INACTIVE
        80        577 dllhost.exe          INACTIVE
        90       1552 dllhost.exe          INACTIVE
        92        732 dllhost.exe          INACTIVE
        94        757 dllhost.exe          INACTIVE
        96       1095 dllhost.exe          INACTIVE

       SID    SERIAL# PROGRAM              STATUS
---------- ---------- -------------------- --------
        97        393 dllhost.exe          INACTIVE
        98         62 dllhost.exe          INACTIVE
       102       1487 dllhost.exe          INACTIVE
       105        682 dllhost.exe          INACTIVE
       106        521 dllhost.exe          INACTIVE
       107        852 dllhost.exe          INACTIVE
       108        730 dllhost.exe          INACTIVE
       109        976 dllhost.exe          INACTIVE
       111        137 dllhost.exe          INACTIVE
       116       1030 dllhost.exe          INACTIVE
       118       3183 dllhost.exe          INACTIVE

       SID    SERIAL# PROGRAM              STATUS
---------- ---------- -------------------- --------
       120        432 dllhost.exe          INACTIVE
       121        366 dllhost.exe          INACTIVE
       122       1033 dllhost.exe          INACTIVE
       124        377 dllhost.exe          INACTIVE
       125       2074 dllhost.exe          INACTIVE
       126        704 dllhost.exe          INACTIVE
       131        137 dllhost.exe          INACTIVE
       133       1073 dllhost.exe          INACTIVE
       135        963 dllhost.exe          INACTIVE
       137        401 dllhost.exe          INACTIVE
       138        488 dllhost.exe          INACTIVE

       SID    SERIAL# PROGRAM              STATUS
---------- ---------- -------------------- --------
       139        433 dllhost.exe          INACTIVE
       141        667 dllhost.exe          INACTIVE
       142       1302 dllhost.exe          INACTIVE
       147       1029 dllhost.exe          INACTIVE
       149       1255 dllhost.exe          INACTIVE
       150       2498 dllhost.exe          INACTIVE
       152        390 dllhost.exe          INACTIVE
       154        493 dllhost.exe          INACTIVE
       155        505 dllhost.exe          INACTIVE
       156        257 dllhost.exe          INACTIVE
       159       3371 dllhost.exe          INACTIVE

       SID    SERIAL# PROGRAM              STATUS
---------- ---------- -------------------- --------
       162        704 dllhost.exe          INACTIVE
       163        668 dllhost.exe          INACTIVE
       164       1459 dllhost.exe          INACTIVE
       165        469 dllhost.exe          INACTIVE
       168        620 dllhost.exe          INACTIVE
       169       1437 dllhost.exe          INACTIVE
       170         57 dllhost.exe          INACTIVE
       171        638 dllhost.exe          INACTIVE
       173        935 dllhost.exe          INACTIVE
       176        389 dllhost.exe          INACTIVE
       177        359 dllhost.exe          INACTIVE

       SID    SERIAL# PROGRAM              STATUS
---------- ---------- -------------------- --------
       178       2623 dllhost.exe          INACTIVE
       179        947 dllhost.exe          INACTIVE
       180       1255 dllhost.exe          INACTIVE
       181       1342 dllhost.exe          INACTIVE
       184       4277 dllhost.exe          INACTIVE

60 rows selected.


SQL> select count(*) from v$session where program ='dllhost.exe' and status = 'INACTIVE';

  COUNT(*)
----------
        60

而后,其KILLED的进程也自动地回收资源
SQL> select count(*) from v$session where status='KILLED';

  COUNT(*)
----------
        12

SQL> select sid,serial#,program,status from v$session where status='KILLED';

       SID    SERIAL# PROGRAM              STATUS
---------- ---------- -------------------- --------
        81        371 dllhost.exe          KILLED
        84        579 dllhost.exe          KILLED
        85        547 dllhost.exe          KILLED
        91        599 dllhost.exe          KILLED
       100       1147 dllhost.exe          KILLED
       103       2018 dllhost.exe          KILLED
       113       1578 dllhost.exe          KILLED
       117       1190 dllhost.exe          KILLED
       148        488 dllhost.exe          KILLED
       174        675 dllhost.exe          KILLED
       182       1055 dllhost.exe          KILLED

       SID    SERIAL# PROGRAM              STATUS
---------- ---------- -------------------- --------
       186       1461 dllhost.exe          KILLED

12 rows selected.

查看未能关联的paddr
SQL> select p.addr from v$process p where pid <> 1
  2  minus
  3  select s.paddr from v$session s;

ADDR
--------
1E53E22C
1E53E5EC
1E5461AC
1E54746C
1E54782C
1E54926C
1E54A52C
1E54E4EC
1E54F02C
1E54F7AC

查找未能关联的spid
select p.spid, p.program, p.addr from v$process p where pid <> 1
and addr not in (select paddr from v$session);


winodows下kill session
orakill sid,spid

linux下kill session
kill -9 spid


问题:COM+怎么自动终止会话?

kill oralce session参考:http://www.oracle-base.com/articles/misc/KillingOracleSessions.php

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9932141/viewspace-665050/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9932141/viewspace-665050/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值