1.死锁查询
建议版本1
select ipad(' ',decode(l.xidusn,0,3,0)) || l.oracle_username User_name,
o.owner,
o.object_name,
o.object_type,
s.sid,
s.serial#,
s.inst_id
from v$locked_object l,
dba_objects o,
v$session s
where l.object_id = o.boject_id
and l.session_id = s.sid
order by o.object_id,
xidusn desc;
版本2
select ipad(' ',decode(l.xidusn,0,3,0)) || l.oracle_username User_name,
o.owner,
o.object_name,
o.object_type,
s.sid,
s.serial#,
s.inst_id
from gv$locked_object l,
dba_objects o,
gv$session s
where l.object_id = o.boject_id
and l.session_id = s.sid
order by o.object_id,
xidusn desc;
2.杀死死锁的进程
alter system kill session 'sid , serial#';
注意:如果数据库为集群存储,需要切换到对应服务器杀死进程
如:inst_id 值:1 2 3 对应三台服务器
10.166.133.1
10.166.133.2
10.166.133.3
| sid | serial# | inst_id |
|---|---|---|
| 111 | 1235 | 1 |
| 111 | 5456 | 2 |
| 111 | 5646 | 3 |
执行SQL
服务器10.166.133.1
alter system kill session '111 , 1235';
服务器10.166.133.2
alter system kill session '111 , 5456';
服务器10.166.133.3
alter system kill session '111 , 5646';
3.注意
步骤1查询出来的进程不一定就是已经死锁的进程,而是正在运行的进程。只有确定对象不在使用,而存在进程则说明对象死锁。
如:采集一张表test_table 的数据,还没有进行采集,没有对表test_table 做任何操作,但是查询出表test_table已经存在进程,则说明表死锁。
版权声明:本文为qq_46411309原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。