mysql trouble shooting---- 从库停止同步lock_wait_timeout_exceeded_try_restarting_transaction
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mysql trouble shooting---- 从库停止同步lock_wait_timeout_exceeded_try_restarting_transaction,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5182字,纯文字阅读大概需要8分钟。
内容图文
![mysql trouble shooting---- 从库停止同步lock_wait_timeout_exceeded_try_restarting_transaction](/upload/InfoBanner/zyjiaocheng/468/ac85bede9b1f411fbf9d967e010fe19b.jpg)
问题描述:
数据库从库停止同步。
问题分析:
show slave status\G;(也可使用show full processlist)
显示 某个update语句出错,Lock wait timeout exceeded; try restarting transaction;
原因是这条语句提交的时候超时堵塞。原因在于另外的一个操作开启了事务,锁定了相应的数据,导致这条操作相同数据的sql出错。
示例,在sql中
(1)开启事务,锁定数据
终端A:
MySQL> begin; (开启事务,开启事务会锁定相关数据)
Query OK, 0 rows affected (0.00 sec)
mysql> update pet set sex="m" where name="Fluffy";(修改)
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from pet;
+--------+--------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+--------+--------+---------+------+------------+------------+
| Bowser | Diane | dog | m | 1979-08-31 | 1995-07-29 |
| Buffy | Harold | dog | f | 1989-05-13 | NULL |
| Claws | Gwen | cat | m | 1994-03-17 | NULL |
| Fang | Benny | dog | m | 2013-02-05 | NULL |
| Fluffy | Harold | cat | m | 2012-09-30 | NULL |
+--------+--------+---------+------+------------+------------+
5 rows in set (0.00 sec)
终端B:
mysql> select * from pet;
+--------+--------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+--------+--------+---------+------+------------+------------+
| Bowser | Diane | dog | m | 1979-08-31 | 1995-07-29 |
| Buffy | Harold | dog | f | 1989-05-13 | NULL |
| Claws | Gwen | cat | m | 1994-03-17 | NULL |
| Fang | Benny | dog | m | 2013-02-05 | NULL |
| Fluffy | Harold | cat | NULL | 2012-09-30 | NULL |
+--------+--------+---------+------+------------+------------+
5 rows in set (0.01 sec)
因为没有提交,所以实际上没有改变。但是会锁定Fluffy这一条数据。导致如下的错误。
终端B:
mysql> update pet set sex="m" where name="Fluffy";
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
(2)提交事务,解锁数据
终端A:
mysql> commit;
Query OK, 0 rows affected (0.10 sec)
终端B:
mysql> select * from pet;
+--------+--------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+--------+--------+---------+------+------------+------------+
| Bowser | Diane | dog | m | 1979-08-31 | 1995-07-29 |
| Buffy | Harold | dog | f | 1989-05-13 | NULL |
| Claws | Gwen | cat | m | 1994-03-17 | NULL |
| Fang | Benny | dog | m | 2013-02-05 | NULL |
| Fluffy | Harold | cat | m | 2012-09-30 | NULL |
+--------+--------+---------+------+------------+------------+
5 rows in set (0.00 sec)
mysql> update pet set sex="f" where name="Fluffy";
Query OK, 1 row affected (0.08 sec)
Rows matched: 1 Changed: 1 Warnings: 0
(3)如果where中的条件是索引字段,那么只会锁定索引对应的条目;如果不是索引字段,那么会锁定整张表。
终端A:
mysql> update pet set sex="f" where death="1995-07-29";
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from pet;
+--------+--------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+--------+--------+---------+------+------------+------------+
| Bowser | Diane | dog | f | 1979-08-31 | 1995-07-29 |
| Buffy | Harold | dog | f | 1989-05-13 | NULL |
| Claws | Gwen | cat | m | 1994-03-17 | NULL |
| Fang | Benny | dog | m | 2013-02-05 | NULL |
| Fluffy | Harold | cat | f | 2012-09-30 | NULL |
+--------+--------+---------+------+------------+------------+
5 rows in set (0.00 sec)
终端B:
mysql> select * from pet;
+--------+--------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+--------+--------+---------+------+------------+------------+
| Bowser | Diane | dog | m | 1979-08-31 | 1995-07-29 |
| Buffy | Harold | dog | f | 1989-05-13 | NULL |
| Claws | Gwen | cat | m | 1994-03-17 | NULL |
| Fang | Benny | dog | m | 2013-02-05 | NULL |
| Fluffy | Harold | cat | f | 2012-09-30 | NULL |
+--------+--------+---------+------+------------+------------+
5 rows in set (0.00 sec)
mysql> update pet set death="2013-07-00" where birth="2013-02-05";
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
解决办法
(1) stop slave; start slave
(2)网上分析说
Mysql ‘Lock wait timeout exceeded; try restarting transaction‘ 解决方案
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
Temporary error: 266: Time-out in NDB, probably caused by deadlock 解决方法:在管理节点的[ndbd default]
区加:
TransactionDeadLockDetectionTimeOut=10000(设置为10秒)默认是1200(1.2秒)按照顺序重新启动各个节点就不会出现问题了。
不过,本身貌似数据库的TransactionDeadLockDetectionTimeOut已经设置很大,而且即使设置很大,如果那边一直锁表,也是解决不了问题的。
mysql trouble shooting---- 从库停止同步lock_wait_timeout_exceeded_try_restarting_transaction
标签:
本文系统来源:http://www.cnblogs.com/zhming26/p/5671034.html
内容总结
以上是互联网集市为您收集整理的mysql trouble shooting---- 从库停止同步lock_wait_timeout_exceeded_try_restarting_transaction全部内容,希望文章能够帮你解决mysql trouble shooting---- 从库停止同步lock_wait_timeout_exceeded_try_restarting_transaction所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。