o任飘零o

别人给了你一滴水,你给了别人些什么?
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

提示分布式事务处理等待锁的解决方法

Posted on 2013-02-04 15:56  o任飘零o  阅读(3087)  评论(0)    收藏  举报

操作数据库过程中,提示分布式事务处理等待锁时,如下图:

 
则说明操作的记录被锁住或死锁了,如果是死锁,则需要使用以下SQL查询出相应的锁:
select A.sid, b.serial#, decode(A.type,     'MR', 'Media Recovery',     'RT','Redo Thread',     'UN','User Name',     'TX', 'Transaction',     'TM', 'DML',     'UL', 'PL/SQL User Lock',     'DX', 'Distributed Xaction',     'CF', 'Control File',     'IS', 'Instance State',     'FS', 'File Set',     'IR', 'Instance Recovery',     'ST', 'Disk Space Transaction',     'TS', 'Temp Segment',     'IV', 'Library Cache Invalida-tion',     'LS', 'Log Start or Switch',     'RW', 'Row Wait',     'SQ', 'Sequence Number',     'TE', 'Extend Table',     'TT', 'Temp Table',     'Unknown') LockType, c.object_name, b.username, b.osuser, decode(a.lmode,   0, 'None',             1, 'Null',             2, 'Row-S',             3, 'Row-X',             4, 'Share',             5, 'S/Row-X',             6, 'Exclusive', 'Unknown') LockMode, B.MACHINE,D.SPID from v$lock a,v$session b,all_objects c,V$PROCESS D where a.sid=b.sid and a.type in ('TM','TX') and c.object_id=a.id1 AND B.PADDR=D.ADDR;

 

 

然后使用以下SQL解锁:

 

alter system kill session 'SID,SERIAL#'

 

 

查看被锁的表:

select   p.spid,a.serial#, c.object_name,b.session_id,b.oracle_username,b.os_user_name   from   v$process   p,v$session   a,   v$locked_object   b,all_objects   c   where   p.addr=a.paddr   and   a.process=b.process   and   c.object_id=b.object_id