今天在试验事务隔离级别demo的时候,出现的这个问题。

org.springframework.dao.CannotAcquireLockException:
### Error updating database.  Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
### The error may exist in file [E:\Java_Gitee\mysql-mybatis-demo\target\classes\config\StockMapper.xml]
### The error may involve com.example.dao.StockMapper.updateStock-Inline
### The error occurred while setting parameters
### SQL: update stock set num = num - 1 where id = ?
### Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction

使用的是mysql数据库,在事务中我使用线程休眠了60秒,我先后启动了两个单元测试去调用同一个事务,所以出现了上边的情况。这明显是锁等待时间超时,所以需要调整innodb_lock_wait_timeout这个参数。
远程登陆后,操作如下:

[root@iZm5e9c4pjvz19yded1r6bZ ~]# mysql -uroot -pmysql@118
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1573
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show variables like 'innodb_lock_wait_timeout';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| innodb_lock_wait_timeout | 50    |
+--------------------------+-------+
1 row in set (0.00 sec)MariaDB [(none)]> set global innodb_lock_wait_timeout=120;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye

重新进入一下,看下修改结果:

[root@iZm5e9c4pjvz19yded1r6bZ ~]# mysql -uroot -pmysql5290@118
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1576
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show variables like 'innodb_lock_wait_timeout';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| innodb_lock_wait_timeout | 120   |
+--------------------------+-------+
1 row in set (0.00 sec)

再测试,没有出现此问题。

Lock wait timeout exceeded相关推荐

  1. java.sql.SQLException: Lock wait timeout exceeded

    2019独角兽企业重金招聘Python工程师标准>>> 先说我我的解决方法:找到锁住的线程然后kill掉. mysql> kill thr_id; 下面简单分析一下到底应该ki ...

  2. 数据库 1205 Error 'Lock wait timeout exceeded; try restarting transaction' on query

    收到报警,mysql的从数据库在同步的过程出现问题,已停止同步. mysql> show slave status\G *************************** 1. row ** ...

  3. mysql 中lock wait_应用中MYSQL 报错Lock wait timeout exceeded; try restarting transaction

    最近开发的应用开始做性能测试.在小于80用户并发的时候一切OK,并发量到100用户时,持续压5分钟.应用开始报错,并且只有1次错误,持续时间长,比如10分钟,会报3次. 日志如下: Caused by ...

  4. Lock wait timeout exceeded; try restarting......

    2019独角兽企业重金招聘Python工程师标准>>> mysql异常java.sql.SQLException: Lock wait timeout exceeded; try r ...

  5. 'Lock wait timeout exceeded; try restarting transaction'问题

    OperationalError: (1205, 'Lock wait timeout exceeded; try restarting transaction') 原因很简单,太多错误,意外处理没有 ...

  6. java.sql.SQLException: Lock wait timeout exceeded --转

    org.springframework.dao.CannotAcquireLockException 的解决> 直接上 bug 的详细信息: 2012-03-12 15:20:31 XmlBea ...

  7. 关于MySQL出现`lock wait timeout exceeded; try restarting transaction` 的解决方案

    关于MySQL出现lock wait timeout exceeded; try restarting transaction 的解决方案. 一.问题抛出 在做查询语句时,MySQL 抛出了这样的异常 ...

  8. MySQL -- Lock wait timeout exceeded; try restarting transaction参数控制

    Lock wait timeout exceeded; try restarting transaction 锁等待超时..回滚事务.. 当事务1  获得锁 start TRANSACTION upd ...

  9. 关于MySQL出现锁等待lock wait timeout exceeded; try restarting transaction 的解决方案

    关于MySQL出现lock wait timeout exceeded; try restarting transaction 的解决方案. 一.问题抛出 在做查询语句时,MySQL 抛出了这样的异常 ...

  10. ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

    前言:朋友咨询我说执行简单的update语句失效,症状如下: mysql> update order_info  set province_id=15  ,city_id= 1667  wher ...

最新文章

  1. 企业网络推广——企业网络推广出于四大目的旨在做好网站营销
  2. 回首2020,我们砥砺前行
  3. 电脑长截图软件_电脑屏幕长截图+WORD文档里没有插入PDF文件选项时怎么办? 简单一招轻松完成...
  4. Hibernate之Hello World篇
  5. 有趣的圣诞节 库的打包
  6. 香港首个港人“首置项目”超额认购逾44倍
  7. SQL查询分析器的使用说明
  8. 编写myqq即时聊天脚本,实现相互通信(tcp协议)
  9. 全网显示 IP 归属地,是怎么实现的?
  10. 监控mysql锁定状态_mysql InnoDB锁等待的查看及分析
  11. 使用CCleaner删除系统还原点
  12. 数据结构(c语言版) 计算机科学丛书,数据结构与算法分析--C语言描述(原书第2版)(计算机科学丛书)...
  13. P02014158 马帅(信息论课程作业)
  14. d3带箭头和点击事件的力导向关系图
  15. 开源工具,又是免费的神器 ,有点意思
  16. 关于找工作---职业规划[转]
  17. I/O error on POST request for “http://localhost:9411/api/v2/spans“
  18. 华为云提出云数据灾备解决方案,该方案在数据安全性、稳定性方面具有绝对的可靠性
  19. 为淘宝网店免费使用流量统计教程
  20. 输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数

热门文章

  1. 只有PHP大牛才能读懂的内涵图
  2. 麦吉尔大学的计算机专业硕士,麦吉尔大学研究生专业设置情况
  3. RNN(pytorch)的维度问题——用GRU实现文本分类(参考刘二大人)
  4. ERROR: child process failed, exited with error number 1
  5. 瑜伽形体棍出口欧盟CE认证,出口美国CPC认证标准介绍
  6. take credit for用法
  7. IntelliJ IDEA Ultimate破解安装及使用其进行Spring程序开发
  8. 琢磨事琢磨人琢磨钱,成大事也!
  9. 吊打何同学?B 站 UP 主 24 小时肝出 AirDesk 平替,成本 6000!
  10. Java多线程游戏-雷霆战机