linbs28
2012-06-27 09:55 阅读 815
已采纳

两条insert语句引起的死锁问题,求解。

使用java编写的批量插入程序,在进行并发测试时出现了数据死锁的问题,查看udump日志信息如下:
*** SESSION ID:(132.130) 2012-06-25 13:39:09.656
DEADLOCK DETECTED ( ORA-00060 )
[Transaction Deadlock]
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock:
Deadlock graph:
                       ---------Blocker(s)--------  ---------Waiter(s)---------
Resource Name          process session holds waits  process session holds waits
TX-00020010-000040de        32     132     X             42     135           S
TX-00060002-00003f89        42     135     X             32     132           S
session 132: DID 0001-0020-00000018 session 135: DID 0001-002A-00000009
session 135: DID 0001-002A-00000009 session 132: DID 0001-0020-00000018
Rows waited on:
Session 135: obj - rowid = 0000F78A - AAAPeKAAAAAAAAAAAA
  (dictionary objn - 63370, file - 0, block - 0, slot - 0)
Session 132: obj - rowid = 0000F78A - AAAPeKAAGAAAl3OAAA
  (dictionary objn - 63370, file - 6, block - 155086, slot - 0)
Information on the OTHER waiting sessions:
Session 135:
  pid=42 serial=591 audsid=230181 user: 72/SHZY2
  O/S info: user: , term: , ospid: 1234, machine: csbyyserver
            program:
  Current SQL Statement:
  insert into t_idx_zxcx (zj,ztlx,glxxbh,hm) values ('6404618','01','238','350212198502090000')
End of information on OTHER waiting sessions.
Current SQL statement for this session:
insert into t_idx_zxcx (zj,ztlx,glxxbh,hm) values ('6403618','01','238','350212198502090000')
===================================================

两个不同的会话在插入的时候,rowid居然一致。一直想不通问题的原因,只能求大牛帮忙了。附上数据库表的设计:
附件1为数据库表设计,附件2为该表的索引,附件3为表的主键设计

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    ll89308839 ll89308839 2012-06-27 11:48

    我也不搬别人的东西,楼主你直接看这个连接吧
    [url]http://blog.csdn.net/icejasmin/article/details/6107623[/url]

    点赞 评论 复制链接分享
  • love398146779 love398146779 2012-06-27 10:39

    没看到你的附件,
    不过可以推测,是因为,第一次插入时失败,所以第二次用的同一个rowid进行插入.
    可能是你的id用的是序列,而此序列已经被手动加入过了.

    点赞 评论 复制链接分享
  • mayufenga1 helloword321 2012-06-29 14:27

    用uuid做主键吧

    点赞 评论 复制链接分享

相关推荐