zoukankan      html  css  js  c++  java
  • 错误调试记录3 并发事物控制及锁得使用

     

     

    错误日志如下:

    2011-05-04 18:23:12,515 ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer#1-2] BatDisburseBoImp.toDisburse(84) | 时间:Wed May 04 18:23:12 CST 2011  内部流水号:WW20110504182312826431   对方订单号:AD283380683  支付失败。

    org.springframework.dao.DeadlockLoserDataAccessException: SqlMapClient operation; SQL [];  

    --- The error occurred while applying a parameter map. 

    --- Check the com.shunwang.swpay.disburse.dao.userAccount.updateCommissionById-InlineParameterMap. 

    --- Check the statement (update failed). 

    --- Cause: java.sql.SQLException: 事务(进程 ID 64)与另一个进程被死锁在 锁 资源上,并且已被选作死锁牺牲品。请重新运行该事务。; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:  

    --- The error occurred while applying a parameter map. 

    --- Check the com.shunwang.swpay.disburse.dao.userAccount.updateCommissionById-InlineParameterMap. 

    --- Check the statement (update failed). 

    --- Cause: java.sql.SQLException: 事务(进程 ID 64)与另一个进程被死锁在 锁 资源上,并且已被选作死锁牺牲品。请重新运行该事务。

    Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:  

    --- The error occurred while applying a parameter map. 

    --- Check the com.shunwang.swpay.disburse.dao.userAccount.updateCommissionById-InlineParameterMap. 

    --- Check the statement (update failed). 

    --- Cause: java.sql.SQLException: 事务(进程 ID 64)与另一个进程被死锁在 锁 资源上,并且已被选作死锁牺牲品。请重新运行该事务。

     

    解决方法: 把ibatIS文件的账户查询锁 HOLDLOCK  改成 XLOCK 。

     

    原因是  : HOLDLOCK   是持有锁 ,在查询里面是共享锁 ,所以会导致死锁。XLOCK 是排他锁。

     

    可用以下代码开两个事物提交来模拟死锁:

    begin tran
    SELECT *
      FROM [swpay].[passport].[user_account] with (HOLDlock) where user_account_id=4
    update  [swpay].[passport].[user_account] with (HOLDlock)
    set user_account_name = 'test'  where user_account_id=4
    commit

  • 相关阅读:
    MD5验签同一字符串得到不同的MD5签名值可能问题之一
    Git本地仓库与远程github同步的时候提示fatal: remote origin already exists 错误解决办法
    SVN Error: Unreadable path encountered; access denied;
    2018年终个人总结
    ant编译无法依赖rt.jar
    ORA-00980: 同义词转换不再有效
    二叉树的深度和广度优先遍历
    Missing HTTP Strict-Transport-Security Header (HSTS) 解决
    单例模式
    sql 替换字段中部分内容
  • 原文地址:https://www.cnblogs.com/alaricblog/p/3264671.html
Copyright © 2011-2022 走看看