问题背景:

数据库内查到锁信息,但数据库内无法杀锁报错ora-00030,采用操作系统kill进程方式处理,进行记录


处理过程:

首先使用语句将进程sid和serial#查出

col OBJECT_NAME for a20  
col OWNER for a20  
set line 300  
select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;

select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;

查出后执行杀锁语句

alter system kill session 'sid,serial#' immediate

正常进程处理结束,异常情况报错0030

会话id不存在

00030, 00000, "User session ID does not exist."

// *Cause: The user session ID no longer exists, probably because the

// session was logged out.

// *Action: Use a valid session ID.


查看等待事件类型

 

select event from v$session_wait where sid=#;

根据sid查出运行的sql

select sql_text from v$session a,v$sqltext_with_newlines b
      where decode(a.sql_hash_value, 0, prev_hash_value, sql_hash_value)=b.hash_value
     and a.sid=&sid order by piece;

查出进程号kill处理

select c.spid  
from v$process c  
where c.addr=(
select b.paddr  
from v$session b  
where b.sid='#' and b.serial#='#');

部分命令反馈

SQL> select sql_text from v$session a,v$sqltext_with_newlines b

  2        where decode(a.sql_hash_value, 0, prev_hash_value, sql_hash_value)=b.hash_value

  3       and a.sid=&sid order by piece;

Enter value for sid: 130

old   3:      and a.sid=&sid order by piece

new   3:      and a.sid=130 order by piece


SQL_TEXT

----------------------------------------------------------------

select local_tran_id, global_tran_fmt, global_oracle_id, global_

foreign_id,        state, status, heuristic_dflt,        session

_vector, reco_vector, 3600*24*(sysdate-reco_time),        3600*2

4*(sysdate-nvl(heuristic_time,fail_time)), global_commit#,

  type#   from pending_trans$  where session_vector != '00000000

'


6 rows selected.


SQL> select event from v$session_wait where sid=130;


EVENT

----------------------------------------------------------------

rdbms ipc message