用这个语句发现有进程阻塞:
declare
mes varchar2(2000);
tmp_id1 number(22);
tmp_id2 number(22);
lk_sid number(22);
tmp_mac varchar2(64);
fl boolean;
begin
fl:=false;
for c1 in (select sid,serial#,machine,lockwait
from v$session
where lockwait is not null) loop
fl:=true;
mes:='sid:'||to_char(c1.sid)||','||c1.machine||'is be locked by sid ';
select id1,id2 into tmp_id1,tmp_id2
from v$lock where sid=c1.sid and kaddr=c1.lockwait;
for c2 in (select sid lk_sid from v$lock where sid!=c1.sid and id1=tmp_id1 and id2=tmp_id2 and block='1') loop
select machine into tmp_mac from v$session where sid=c2.lk_sid;
dbms_output.put_line(mes||to_char(c2.lk_sid)||' '||tmp_mac);
end loop;
end loop;
if not fl then
dbms_output.put_line('目前系统中没有互锁现象');
end if;
end;
/
sid:96,jupiteris be locked by sid 177 jupiter
sid:119,WORKGROUP\PZZHANG
sid:157,jupiteris be locked by sid 177 jupiter
sid:173,jupiteris be locked by sid 177 jupiter
sid:180,jupiteris be locked by sid 177 jupiter
发现有几个进程被177锁住.而177执行的sql语句是
select SQL_TEXT, c.spid, b.sid,b.USERNAME
from V$SQLAREA a, v$session b, v$process c
where b.SQL_ADDRESS = a.ADDRESS
and b.SQL_HASH_VALUE = a.HASH_VALUE
and c.ADDR = b.paddr
and b.sid = 177;
/
select this_.id as id0_,
this_.name as name2_0_,
this_.password as password2_0_,
this_.mobile as mobile2_0_,
this_.status as status2_0_,
this_.email as email2_0_,
this_.code as code2_0_,
this_.birthday as birthday2_0_,
this_.gender as gender2_0_,
this_.region as region2_0_,
this_.real_name as real11_2_0_,
this_.user_agent as user12_2_0_,
this_.home as home2_0_,
this_.logo as logo2_0_,
this_.latest_login_date as latest15_2_0_,
this_.creation_date as creation16_2_0_
from imeg_user this_
where this_.mobile = :1
and this_.status <> :2
程序员说这条sql语句是通过中间件生成的,继续调查发现177进程的这条语句持有的锁的lock_type有Transaction enqueue lock和DML enqueue lock.持有的锁的lock_mode有Row Exclusive和Exclusive.这样看起来和一般的update持有的锁一样.
其他几个被锁住的进程都是在执行
update imeg_user set latest_login_date=:1 where id=:2
数据库是9201,这种情况是什么问题?