现在有一个程序,大致情况如下:
insert into A values(每次数据不一样);
commit;
exec sql declare cur1 cursor for
select c1,c2,c3,c4,c5
fromA
where ...
order by c2, c3,c4
for update ;
然后open这个cursor
exec sql open cur1;
while(1)
{
fetch cur1 into :v1,:v2,:v3,:v4,:v5;
if(sqlca.sqlcode==notfound)break;
....
exec sql update A set c1=XX where current of cur1;
}
然后同时并发N个这样的程序,结果其中两个进程出现了deadlock,都锁在select c1,c2,c3,c4,c5fromAwhere ... order by c2, c3,c4for update 这句上面,是在open的时候死锁。
我知道for update会引起锁等待,这个没有问题,但现在是为什么会出现600死锁呢?因为前面的insert已经commit了,为什么会在open cursor的时候死锁呢?请各位帮忙指教
|