下面是打印的日志的一部分:
2013-12-24 16:59:59 [http-8888-17:3236579] - [INFO] http-8888-17:日志新增开始
2013-12-24 16:59:59 [http-8888-8:3236588] - [INFO] http-8888-8:event开始--新增
2013-12-24 16:59:59 [http-8888-10:3236620] - [INFO] http-8888-10:event结束--新增
2013-12-24 16:59:59 [http-8888-10:3236621] - [INFO] http-8888-10:tags开始
2013-12-24 16:59:59 [http-8888-10:3236621] - [INFO] http-8888-10:tags结束
2013-12-24 16:59:59 [http-8888-10:3236628] - [INFO] http-8888-10:关系开始
2013-12-24 16:59:59 [http-8888-10:3236628] - [INFO] http-8888-10:删除关系开始
2013-12-24 16:59:59 [http-8888-11:3236675] - [ERROR] http-8888-11could not insert: [com.shunwang.itsupport.daily.pojo.EventTag]
2013-12-24 16:59:59 [http-8888-10:3236705] - [INFO] http-8888-10:删除关系结束
2013-12-24 16:59:59 [http-8888-10:3236705] - [INFO] http-8888-10:建立关系开始
2013-12-24 16:59:59 [http-8888-3:3236716] - [INFO] http-8888-3:event结束--新增
2013-12-24 16:59:59 [http-8888-14:3236716] - [INFO] http-8888-14:event结束--新增
2013-12-24 16:59:59 [http-8888-14:3236716] - [INFO] http-8888-14:tags开始
2013-12-24 16:59:59 [http-8888-3:3236716] - [INFO] http-8888-3:tags开始
2013-12-24 16:59:59 [http-8888-3:3236716] - [INFO] http-8888-3:tags结束
2013-12-24 16:59:59 [http-8888-14:3236716] - [INFO] http-8888-14:tags结束
2013-12-24 16:59:59 [http-8888-15:3236722] - [INFO] http-8888-15:event结束--新增
2013-12-24 16:59:59 [http-8888-15:3236723] - [INFO] http-8888-15:tags开始
2013-12-24 16:59:59 [http-8888-15:3236723] - [INFO] http-8888-15:tags结束
2013-12-24 16:59:59 [http-8888-2:3236724] - [INFO] http-8888-2:event结束--新增
2013-12-24 16:59:59 [http-8888-2:3236724] - [INFO] http-8888-2:tags开始
2013-12-24 16:59:59 [http-8888-2:3236724] - [INFO] http-8888-2:tags结束
2013-12-24 16:59:59 [http-8888-10:3236732] - [INFO] http-8888-10:建立关系
2013-12-24 16:59:59 [http-8888-14:3236735] - [INFO] http-8888-14:关系开始
2013-12-24 16:59:59 [http-8888-14:3236746] - [INFO] http-8888-14:删除关系开始
2013-12-24 16:59:59 [http-8888-10:3236745] - [INFO] http-8888-10:建立关系
2013-12-24 16:59:59 [http-8888-15:3236753] - [INFO] http-8888-15:关系开始
2013-12-24 16:59:59 [http-8888-15:3236753] - [INFO] http-8888-15:删除关系开始
2013-12-24 17:00:00 [http-8888-14:3236790] - [INFO] http-8888-14:删除关系结束
2013-12-24 17:00:00 [http-8888-14:3236790] - [INFO] http-8888-14:建立关系开始
2013-12-24 17:00:00 [http-8888-2:3236791] - [INFO] http-8888-2:关系开始
2013-12-24 17:00:00 [http-8888-2:3236792] - [INFO] http-8888-2:删除关系开始
2013-12-24 17:00:00 [http-8888-3:3236793] - [INFO] http-8888-3:关系开始
2013-12-24 17:00:00 [http-8888-3:3236793] - [INFO] http-8888-3:删除关系开始
2013-12-24 17:00:00 [http-8888-10:3236795] - [INFO] http-8888-10:建立关系
2013-12-24 17:00:00 [http-8888-10:3236795] - [INFO] http-8888-10:建立关系结束
2013-12-24 17:00:00 [http-8888-10:3236795] - [INFO] http-8888-10:关系结束
2013-12-24 17:00:00 [http-8888-10:3236808] - [INFO] http-8888-10:日志新增结束
2013-12-24 17:00:00 [http-8888-15:3236817] - [INFO] http-8888-15:删除关系结束
2013-12-24 17:00:00 [http-8888-15:3236817] - [INFO] http-8888-15:建立关系开始
2013-12-24 17:00:00 [http-8888-17:3236819] - [INFO] http-8888-17:event开始--新增
2013-12-24 17:00:00 [http-8888-2:3236820] - [INFO] http-8888-2:删除关系结束
2013-12-24 17:00:00 [http-8888-2:3236821] - [INFO] http-8888-2:建立关系开始
2013-12-24 17:00:00 [http-8888-3:3236824] - [INFO] http-8888-3:删除关系结束
2013-12-24 17:00:00 [http-8888-3:3236824] - [INFO] http-8888-3:建立关系开始
2013-12-24 17:00:00 [http-8888-8:3236825] - [INFO] http-8888-8:event结束--新增
2013-12-24 17:00:00 [http-8888-8:3236826] - [INFO] http-8888-8:tags开始
2013-12-24 17:00:00 [http-8888-8:3236826] - [INFO] http-8888-8:tags结束
2013-12-24 17:00:00 [http-8888-14:3236830] - [INFO] http-8888-14:建立关系
2013-12-24 17:00:00 [http-8888-14:3236837] - [WARN] SQL Error: 1213, SQLState: 40001
2013-12-24 17:00:00 [http-8888-14:3236837] - [ERROR] Deadlock found when trying to get lock; try restarting transaction
2013-12-24 17:00:00 [http-8888-2:3236839] - [WARN] SQL Error: 1213, SQLState: 40001
2013-12-24 17:00:00 [http-8888-2:3236839] - [ERROR] Deadlock found when trying to get lock; try restarting transaction
2013-12-24 17:00:00 [http-8888-9:3236843] - [INFO] sessionId:EB0E51048906BE17D510C58B4F67E239-n1.tomcathzh2  地址:/dailyservice/front/event/events
2013-12-24 17:00:00 [http-8888-9:3236843] - [INFO] sessionId:EB0E51048906BE17D510C58B4F67E239-n1.tomcathzh2的 session有效
2013-12-24 17:00:00 [http-8888-3:3236844] - [WARN] SQL Error: 1213, SQLState: 40001
2013-12-24 17:00:00 [http-8888-3:3236844] - [ERROR] Deadlock found when trying to get lock; try restarting transaction
2013-12-24 17:00:00 [http-8888-8:3236848] - [INFO] http-8888-8:关系开始
2013-12-24 17:00:00 [http-8888-8:3236848] - [INFO] http-8888-8:删除关系开始
2013-12-24 17:00:00 [http-8888-5:3236860] - [INFO] sessionId:FCB9943FA57F5931C1102FED3EDA1BBB-n1.tomcathzh2  地址:/dailyservice/front/event/events
2013-12-24 17:00:00 [http-8888-5:3236860] - [INFO] sessionId:FCB9943FA57F5931C1102FED3EDA1BBB-n1.tomcathzh2的 session有效
2013-12-24 17:00:00 [http-8888-15:3236848] - [INFO] http-8888-15:建立关系
2013-12-24 17:00:00 [http-8888-11:3236886] - [INFO] sessionId:797C062FBC1C951F583C1A936D5E4E42-n1.tomcathzh2  地址:/dailyservice/front/event/events
2013-12-24 17:00:00 [http-8888-14:3236891] - [ERROR] http-8888-14could not insert: [com.shunwang.itsupport.daily.pojo.EventTag]
2013-12-24 17:00:00 [http-8888-11:3236891] - [INFO] sessionId:797C062FBC1C951F583C1A936D5E4E42-n1.tomcathzh2的 session有效
2013-12-24 17:00:00 [http-8888-2:3236899] - [ERROR] http-8888-2could not insert: [com.shunwang.itsupport.daily.pojo.EventTag]
2013-12-24 17:00:00 [http-8888-8:3236900] - [INFO] http-8888-8:删除关系结束
2013-12-24 17:00:00 [http-8888-8:3236900] - [INFO] http-8888-8:建立关系开始
2013-12-24 17:00:00 [http-8888-3:3236911] - [ERROR] http-8888-3could not insert: [com.shunwang.itsupport.daily.pojo.EventTag]
2013-12-24 17:00:00 [http-8888-15:3236912] - [INFO] http-8888-15:建立关系
2013-12-24 17:00:00 [http-8888-8:3236917] - [WARN] SQL Error: 1213, SQLState: 40001
2013-12-24 17:00:00 [http-8888-8:3236918] - [ERROR] Deadlock found when trying to get lock; try restarting transaction
2013-12-24 17:00:00 [http-8888-15:3236947] - [INFO] http-8888-15:建立关系
2013-12-24 17:00:00 [http-8888-15:3236947] - [INFO] http-8888-15:建立关系结束
2013-12-24 17:00:00 [http-8888-15:3236947] - [INFO] http-8888-15:关系结束
2013-12-24 17:00:00 [http-8888-18:3236954] - [INFO] sessionId:954C1EC3CA0B04934EB4749F66AEE6D5-n1.tomcathzh2  地址:/dailyservice/front/event/events
2013-12-24 17:00:00 [http-8888-18:3236955] - [INFO] sessionId:954C1EC3CA0B04934EB4749F66AEE6D5-n1.tomcathzh2的 session有效
2013-12-24 17:00:00 [http-8888-17:3236961] - [INFO] http-8888-17:event结束--新增
2013-12-24 17:00:00 [http-8888-17:3236961] - [INFO] http-8888-17:tags开始
2013-12-24 17:00:00 [http-8888-17:3236962] - [INFO] http-8888-17:tags结束
2013-12-24 17:00:00 [http-8888-8:3236974] - [ERROR] http-8888-8could not insert: [com.shunwang.itsupport.daily.pojo.EventTag]
2013-12-24 17:00:00 [http-8888-15:3236984] - [INFO] http-8888-15:日志新增结束
2013-12-24 17:00:00 [http-8888-17:3236984] - [INFO] http-8888-17:关系开始

解决方案 »

  1.   

    补充一下:
    数据库是mysql  
    用的InnoDB 存储引擎
    隔离级别是默认的Repeatable Read各位,帮忙看看吧,实在是没明白产生死锁的原因!
      

  2.   

    涉及到线程安全的问题了。sychronized 解决
      

  3.   

    这个建议采用存储过程执行,
    func_** 
    begin
    lock table ** in exclusive mode;
     do
    end
    这样多线程是能确保正常
      

  4.   

    请教DBA后,可以确定在对EventTag表进行删除操作的时候,由于间隙锁导致死锁问题。有两种办法
    降低隔离级别
    或者对eventId 做唯一性
    我这里打算降低隔离级别