远程快速杀死session!

今天有一个开发的哥们A(不方面透露信息,暂叫A),在群里发问:
表中插入大数据量的时候卡住了,一查发现是锁住了,已经kill session,但是总是解锁不了,状态是killed,释放不了锁,并且删除操作的表,也不行,提示资源正忙。
当时只是草率的说:
去os中 直接  kill  -9  spid
后来这位哥们给我发该怎么弄:
我让他查:
 select  spid,username,terminal,program from  v$process where addr in (select  paddr from  v$session  where username=XXX) ;

A给的截图:

s elect object_name,machine,s.sid,s.serial# 
from v$locked_object l,dba_objects o ,v$session s
where l.object_id = o.object_id and l.session_id=s.sid;

他同时给我找个截图:

然后让他在os下执行:
kill  -9  spid;(LINUX)
orakill 实例  thread (Windows)
这时他说他是远程数据库,而且不能ssh登陆服务器主机,这个是挺头疼的!
我让他再一次:
alter system kill session '428,310';

alter system kill session '727,862';

alter system kill session '304,365';
此时还没有解决问题:



这时A说已经解决了:
 alter system kill session '727,862' immediate; 
加了一个强制immediate


一般情况下,在杀死一个session时,直接alter  system  kill  session  ‘sid,serial#'
当session还是active的时候,这是将session标识为killed或者pseudo,并不会释放session所持有的资源,所以会话一直存在( The ALTER SYSTEM  statement does not implicitly commit the current transaction.)
官方网站上:(http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_2014.htm#SQLRF00902
If the session is performing some activity that must be completed, such as waiting for a reply from a remote database or rolling back a transaction, then Oracle Database waits for this activity to complete, marks the session as terminated, and then returns control to you. If the waiting lasts a minute, then Oracle Database marks the session to be terminated and returns control to you with a message that the session is marked to be terminated. ThePMON  background process then marks the session as terminated when the activity is complete.
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.
通过上面学习了如何远程快速杀死session,平时习惯于依赖os命令,正好今天上了一课!同时也感谢A!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值