這種通常是等鎖超時了,能夠設置延長等鎖時間。mysql
mysql> set innodb_lock_wait_timeout=100 Query OK, 0 rows affected (0.02 sec) 查詢當前等鎖時間 mysql> show variables like 'innodb_lock_wait_timeout'; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | innodb_lock_wait_timeout | 100 | +--------------------------+-------+
但咱們更傾向於找出耗時長的sql,看是哪裏hold住了。
SHOW ENGINE INNODB STATUS\G
You can see list of locked tables by-sql
show open tables where in_use>0;
查看當前在用的線程。
show full processlist;若是是以前的線程,能夠查看慢日誌。先到 Mysql的配置文件查看slow log的日誌目錄,再到該目錄查看日誌。