MySQL Fix for Error Code: 1205. Lock wait timeout exceeded; try restarting transaction

This can mostly occur when you are trying to insert or update a table but there is a pending transaction thats locked some table. I run into these during my test units when inserting or updated test data and if there is a exception in between. Perils of good programming yeah! 😀

Anyways in order to diagnose this we need to connect to MySQL sever using the root access.

From your MySQL Workbench or mysql prompt run the below command.

SHOW ENGINE INNODB STATUS ;

Copy the contents of column status into a text editor and look for the lines.

mysql tables in use 1, locked 1

Under this you can see the MySQL thread id which shows the erring query that seems to have locked out the table. copy the id of this thread and proceed to kill the process.

MySQL thread id 60525, OS thread handle 0x7fd90c209700, query id 2102784 

Take caution before running the below command and ensure you know the consequences of killing a process, if in doubt refer to an experienced DBA.

Kill 60525;

Please like & share:

Leave a Reply

  

  

  


*