查看锁信息如下:
SQL> with lk as (select blocking_instance||‘.‘||blocking_session blocker, inst_id||‘.‘||sid waiter
2 from gv$session
3 where blocking_instance is not null
4 and blocking_session is not null)
5 select lpad(‘ ‘,2*(level-1))||waiter lock_tree from
6 (select * from lk
7 union all
8 select distinct ‘root‘, blocker from lk
9 where blocker not in (select waiter from lk))
10 connect by prior waiter=blocker start with blocker=‘root‘;
LOCK_TREE
-------------------------------------------------------------------------------
1.71
1.1349
2.136
与客户方负责人确认后,Kill持锁session:
SQL> alter system kill session ‘71,36519‘;
alter system kill session ‘71,36519‘
*
ERROR at line 1:
ORA-00031: session marked for kill
SQL> select spid, osuser, s.program from v$session s, v$process p where s.paddr = p.addr and s.sid =71;
SPID OSUSER PROGRAM
------------------------ ------------------------------
16783
[oracle@testrac2 ~]$ kill -9 16783
约3秒后再查:
[oracle@testrac2 ~]$ kill -9 16783
-bash: kill: (16783) - No such process
SQL> select sid,serial# from v$session where sid=1349;
SID SERIAL#
---------- ----------
1349 3539
Kill该session同样报错ORA-00031: session marked for kill。
SQL> select spid, osuser, s.program from v$session s, v$process p where s.paddr = p.addr and s.sid =1349;
SPID OSUSER PROGRAM
------------------------ ------------------------------
8581
SQL> select spid, osuser, s.program from v$session s, v$process p where s.paddr = p.addr and s.sid =1349;
SPID OSUSER PROGRAM
------------------------ ------------------------------
8581
约5秒后再查:
[oracle@testrac2 ~]$ kill -9 8581
-bash: kill: (8581) - No such process
分析:
期间查到1.71进程(每次行锁的持有者进程)正在执行的sql语句为:
SQL> select sid,sql_text from v$session a,v$sql b where sid in(71) and (b.sql_id=a.sql_id or b.sql_id=a.prev_sql_id);
查询结果为一个insert语句。