ERROR 1205 (HY000): Lock wait timeout exceeded

Posted 雅冰石

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ERROR 1205 (HY000): Lock wait timeout exceeded相关的知识,希望对你有一定的参考价值。

一 问题描述

执行一个普通的update报错:

ERROR 1205 (HY000): Lock wait timeout exceeded

二 排查思路

查看是否有阻塞:

SELECT    
        p2.`HOST` Blockedhost,
p2.`USER` BlockedUser,
r.trx_id BlockedTrxId,    
        r.trx_mysql_thread_id BlockedThreadId,    
        TIMESTAMPDIFF(    
            SECOND,    
            r.trx_wait_started,    
            CURRENT_TIMESTAMP    
        ) WaitTime,    
        r.trx_query BlockedQuery,    
        l.lock_table BlockedTable,  
        m.`lock_mode` BlockedLockMode,
        m.`lock_type` BlockedLockType,
        m.`lock_index` BlockedLockIndex,
        m.`lock_space` BlockedLockSpace,
        m.lock_page BlockedLockPage,
        m.lock_rec BlockedLockRec,
        m.lock_data BlockedLockData, 
        p.`HOST` blocking_host, 
        p.`USER` blocking_user,
        b.trx_id BlockingTrxid,    
        b.trx_mysql_thread_id BlockingThreadId,
        b.trx_query BlockingQuery,
        l.`lock_mode` BlockingLockMode,
        l.`lock_type` BlockingLockType,
        l.`lock_index` BlockingLockIndex,
        l.`lock_space` BlockingLockSpace,
        l.lock_page BlockingLockPage,
        l.lock_rec BlockingLockRec,
        l.lock_data BlockingLockData,         
       IF (p.COMMAND = 'Sleep', CONCAT(p.TIME,' seconds'), 0) idel_in_trx             
    FROM    
        information_schema.INNODB_LOCK_WAITS w    
    INNER JOIN information_schema.INNODB_TRX b ON b.trx_id = w.blocking_trx_id    
    INNER JOIN information_schema.INNODB_TRX r ON r.trx_id = w.requesting_trx_id    
    INNER JOIN information_schema.INNODB_LOCKS l ON w.blocking_lock_id = l.lock_id  AND l.`lock_trx_id`=b.`trx_id`
      INNER JOIN information_schema.INNODB_LOCKS m ON m.`lock_id`=w.`requested_lock_id` AND m.`lock_trx_id`=r.`trx_id`
    INNER JOIN information_schema. PROCESSLIST p ON p.ID = b.trx_mysql_thread_id   
 INNER JOIN information_schema. PROCESSLIST p2 ON p2.ID = r.trx_mysql_thread_id 
    ORDER BY    
        WaitTime DESC

发现阻塞方竟然是一个commit语句,我们设置的是自动提交呀。

然后执行SELECT * FROM information_schema.processlist WHERE info IS NOT NULL
ORDER BY TIME DESC;发现报错,磁盘空间不足。

发现磁盘空间百分百了,估计是磁盘空间100%,导致无法commit,进而导致无法update。

三 解决办法

清理binlog。示例:

#查看有哪些binlog

SHOW BINARY LOGS;

#清理slave-bin.000395之前的binlog

PURGE BINARY LOGS TO 'slave-bin.000395';

以上是关于ERROR 1205 (HY000): Lock wait timeout exceeded的主要内容,如果未能解决你的问题,请参考以下文章

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

ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction解决办法

ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction解决

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

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

执行 update操作的时候有报错 ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction