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

  • 相关阅读:
    jQuery EasyUI API 中文文档
    easyui datagrid使用
    Jquery EasyUI的添加,修改,删除,查询等基本操作介绍
    JQueryEasyUI datagrid框架的基本使用
    使用easyUI 创建复杂的toolbar到datagrid
    转换和删除重复命令tr
    格式化文本数据抽取工具awk
    流编辑器sed
    查找文本工具grep
    查找文件工具find
  • 原文地址:https://www.cnblogs.com/alaricblog/p/3264671.html
Copyright © 2011-2022 走看看