Mysql Lock wait timeout exceeded processing method

Mysql Lock wait timeout exceeded processing method

1. A question

When working on a project today, I suddenly encountered the following problem

img

What's going on, this interface has been normal before. Judging from the error results, it should be a problem with the database.

img

Execute this update statement and find that the lock connection of the database has timed out

2. Solutions

-- 当前运行的所有事务
SELECT * FROM information_schema.INNODB_TRX;

Execute the above statement, the result is as follows (the timeout transaction has been killed by me, so there is no data)

image-20201216175719646

See if there is a locked transaction thread in the transaction table INNODB_TRX, if there is a locked transaction, find its trx_mysql_thread_id,

-- 查看数据库当前的进程
show  processlist;

Check whether there is this id in the current process of the database. If it exists, it proves that the sleep thread transaction has not been committed or rolled back but stuck, and we need to kill it manually.

-- kill 命令(kill 加上 id值)
kill id

At this time, it was found that the update was normal

Guess you like

Origin blog.csdn.net/wgzblog/article/details/111299570