How to debug Lock wait timeout exceeded on MySQL?

前端 未结 11 948
我寻月下人不归
我寻月下人不归 2020-11-22 11:46

In my production error logs I occasionally see:

SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 12:19

    Extrapolating from Rolando's answer above, it is these that are blocking your query:

    ---TRANSACTION 0 620783788, not started, process no 29956, OS thread id 1196472640
    MySQL thread id 5341773, query id 189708353 10.64.89.143 viget
    

    If you need to execute your query and can not wait for the others to run, kill them off using the MySQL thread id:

    kill 5341773 
    

    (from within mysql, not the shell, obviously)

    You have to find the thread IDs from the:

    show engine innodb status\G
    

    command, and figure out which one is the one that is blocking the database.

提交回复
热议问题