ORA-00031 session marked for kill

2021-08-17 15:39:13 浏览数 (1)

About ORA-00031

代码语言:javascript复制
Error:  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 uninterruptable 
	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. 

当KILL语句执行后,报这样的信息:ORA-00031  session marked for kill

该怎么办呢  ?

首先、需要判断是否是回滚(rollback)进程,如果是回滚进程,则等待它回滚完成。

代码语言:javascript复制
--判断当前是否有回滚事务
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select usn,
       state,
       undoblockstotal "Total",
       undoblocksdone "Done",
       undoblockstotal - undoblocksdone "ToDo",
       decode(cputime,
              0,
              'unknown',
              sysdate   (((undoblockstotal - undoblocksdone) /
              (undoblocksdone / cputime)) / 86400)) "Estimated time to complete"
  from v$fast_start_transactions
  where state = 'RECOVERING';

一、查找系统进程ID

执行如下语句,查出被锁的进程的ID:

代码语言:javascript复制
-- 执行以下SQL,需要DBA的权限

--1.通过sid查询SPID
select spid from v$process where addr in (select paddr from v$session where sid=1323);

--2.查询条件 KILLED ,必须大写
SELECT P.SPID, S.SID, S.SERIAL#, S.USERNAME, S.PROGRAM
FROM V$PROCESS P, V$SESSION S
WHERE P.ADDR=S.PADDR AND S.STATUS='KILLED';

二、系统层面 KILL 进程

1、LINUX

代码语言:javascript复制
## $SPID 为 第1步的sql查出的SPID

kill –9 $SPID

2、WINDOWS

代码语言:javascript复制
## $SPID 为 第1步的sql查出的SPID

##name为数据库实例名
select instance_name from gv$instance;

##cmd命令行执行
orakill 数据库实例名 $SPID

Notes:orakill 是Oracle自带的一个服务

0 人点赞