【发布时间】:2015-04-27 14:06:19
【问题描述】:
我将 Oracle Coherence 与 sybase 表一起用作数据的后备存储。 我的 java 程序将数据插入到 coherence 缓存中,然后通过存储过程将数据写入表中。
批量记录的代码调用存储过程如下所示
begin
beging tran
update tableA
set
col1=val1,
col2=val2
where
col3=val3
if(@@rowcount=0)
insert into tableA
(
col1,
col2,
col3
)
values
(
val1,
val2,
val3
)
if(@@error=0)
begin
rollback tran
end
commit tran
end
近 50 个线程可以通过调用 execureBatch 来调用该过程,其中一个批处理包含近 125 条记录,但是所有记录相互不同,并且表得到了数据行锁定。
但是通过 BatchUpdateException 获得死锁错误
java.sql.BatchUpdateException: Your server command (family id #0, process id #464) encountered a deadlock situation. Please re-run your command.
这里出现死锁的原因是什么?
【问题讨论】:
标签: java sap-ase database-deadlocks oracle-coherence