MySQL中执行update SQL时,报错:1205, 'Lock wait timeout,是什么原因导致的?
1205, 'Lock wait timeout exceeded; try restarting transaction'
SET AUTOCOMMIT = 0; UPDATE .... COMMIT;
And you disconnect the client ( ip failover, ... ) after the autocommit was set to 0, but before the commit statement is reached, the transaction hangs there indefinitely. When the SQL thread for the replication want to write the updates ( that are now handled on the second mysql server ), it wait for the locks to be released, and fails 10 times after 50 seconds each, causing mysql replication to halt.
Mysql的 InnoDB存储引擎是支持事务的,事务开启后没有被主动Commit,导致该资源被长期占用,其他事务在抢占该资源时,因上一个事务的锁而导致抢占失败!因此出现 Lock wait timeout exceeded
解决办法: 方法一: 1. 查看事物表,找出被锁线程的id:SELECT * FROM information_schema.INNODB_TRX; kill id
方法二: 1. 执行MySQL命令:SHOW FULL PROCESSLIST; 找到被锁住的线程ID kill id
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。