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

  • 相关阅读:
    leetcode_09_Palindrome Number (easy)
    JQuery与JavaScript与Ajax三者的区别与联系
    Blockly常用函数
    JavaWeb中四大域对象
    Thymeleaf知识
    列表、字典、元组、集合的区别
    Spring Boot拦截器
    AWS路由表
    Android调试工具DDMS的使用详解
    Android 列表单选对话框
  • 原文地址:https://www.cnblogs.com/alaricblog/p/3264671.html
Copyright © 2011-2022 走看看