开发者社区> 问答> 正文

MySQL中执行update SQL时,报错:1205, 'Lock wait timeout?

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.

展开
收起
晓风瑟瑟 2021-10-14 22:24:11 928 0
1 条回答
写回答
取消 提交回答
  • 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

    2021-10-15 23:00:33
    赞同 1 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
搭建电商项目架构连接MySQL 立即下载
搭建4层电商项目架构,实战连接MySQL 立即下载
PolarDB MySQL引擎重磅功能及产品能力盛大发布 立即下载

相关镜像