mysql 的一个死锁问题解决
来源:互联网 发布:上海软件市场 编辑:程序博客网 时间:2024/04/30 14:45
这里说的是innodb类型的死锁!
网上找了好多东西 各种命令查看死锁信息,后面这条能用:
show engine innodb status;(根据mysql版本而异)
这命令在mysql命令行执行后如果有死锁
会出现下面这一块:
------------------------
LATEST DETECTED DEADLOCK
------------------------
然后你可以根据这块内容找到你引起死锁的语句。
然后解决它,
我这次的死锁是因为,
有这么一条语句
update 表名 set xx=xxx where xxx=xxx!
其中xxx没有索引!
innodb是行级锁,但是mysql的机制是用索引来找到该行,如果你那个where字段没有索引,那么mysql就找不到那一行,就会锁整张表了
这样后面的访问就会引发死锁!
给xxx字段加上索引
解决问题。附上异常信息:
Caused by: org.springframework.dao.DeadlockLoserDataAccessException: SqlMapClient operation; SQL [];
--- The error occurred while applying a parameter map.
--- Check the point.updatePointAccount-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: com.mysql.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred while applying a parameter map.
--- Check the point.updatePointAccount-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: com.mysql.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:300)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)
at org.springframework.orm.ibatis.SqlMapClientTemplate.update(SqlMapClientTemplate.java:411)
at com.hsd.popularize.dao.BaseDaoImpl.update(BaseDaoImpl.java:162)
... 87 more
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred while applying a parameter map.
--- Check the point.updatePointAccount-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: com.mysql.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
at org.springframework.orm.ibatis.SqlMapClientTemplate$10.doInSqlMapClient(SqlMapClientTemplate.java:413)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
... 89 more
Caused by: com.mysql.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:941)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1169)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:693)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:794)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:989)
at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:62)
at com.sun.proxy.$Proxy20.execute(Unknown Source)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:81)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
... 93 more
- mysql 的一个死锁问题解决
- 分享一个MySQL死锁问题解决的方法
- mysql 的一个死锁问题解决,MySQL wait_timeout参数设置
- mysql 的一个死锁问题
- mysql 一个死锁的分析
- mysql 死锁问题解决
- MySQL一次死锁问题解决记录
- mysql的死锁等6个实战问题解决
- 一个MySQL死锁问题的解决
- 一个最不可思议的MySQL死锁分析
- 一个最不可思议的MySQL死锁分析
- 一个最不可思议的MySQL死锁分析
- 一个最不可思议的MySQL死锁分析
- 一个最不可思议的 MySQL 死锁分析
- 一个最不可思议的MySQL死锁分析
- 一个mysql死锁问题的分析
- 线程退出死锁的问题解决
- 一个MySQL死锁问题的分析及解决
- erlang下A*算法的效率优化过程
- ***(leetcode) (tree) Flatten Binary Tree to Linked List
- CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- C#生成随机数
- 搭建并运行基于HA模式的canal
- mysql 的一个死锁问题解决
- jquery 自带的提示样式
- 自定义控件例如LinearLayout 的三种方法
- 海淘记录第二
- SQL锁表语句
- 客户端会话成功连接至Oracle服务端后,监听的启动和关闭就不会影响已经连接的会话
- DB2 操作无效:已关闭 result set。 ERRORCODE=-4470, SQLSTATE=null
- PL/SQL的存储过程和函数
- 多媒体音视频常用编解码标准介绍