`

ORA-00031: session marked for kill 关于oracle的锁表处理

 
阅读更多

一些操作ORACLE中的进程被杀掉后,状态被置为"killed",但是锁定的资源很长时间不释放,实在没办法的时候,只好重启数据库。但这也不是最佳的解决方案,现在提供一种方法解决这种问题,那就是在ORACLE中杀不掉的,在OS一级再杀。

 

1.下面的语句用来查询哪些对象被锁:


select 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;

 

2.下面的语句用来杀死一个进程:
alter system kill session '24,111'; (其中24,111分别是上面查询出的sid,serial#)

 

 

如果通过以上方法不能解除锁定状态,则用以下方法:

ORA-00031: session marked for kill


Cause: The session specified in an ALTER SYSTEM KILL SESSION command cannot be killed immediately (because it is rolling back or blocked on a network operation), but it has been marked for kill. This means it will be killed as soon as possible after its current uninterruptible operation is done.

Action: No action is required for the session to be killed, but further executions of the ALTER SYSTEM KILL SESSION command on this session may cause the session to be killed sooner.

 

 

首先执行下面的语句获得进程(线程)号:
select spid, osuser, s.program
from v$session s,v$process p
where s.paddr=p.addr and s.sid=24 (24是上面的sid)

 

 

然后在OS上杀死这个进程(线程):
1)在unix上,用root身份或是相应的oracle身份执行命令:
#kill -9 12345(即第3步查询出的spid)
2)在windows(unix也适用)用orakill杀死线程,orakill是oracle提供的一个可执行命令,语法为:
orakill sid thread
其中:
sid:表示要杀死的进程属于的实例名
thread:是要杀掉的线程号,即第3步查询出的spid。
例:c:>orakill orcl 12345

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics