Lock wait timeout exceeded; try restarting transaction in MySQL

Today while I was trying to clean up the MySQL Database, I got the following error:
Error Code : 1205
Lock wait timeout exceeded; try restarting transaction
(0 ms taken)

I was surprise to see this error as the same query was working fine before few minutes and then what happen all of sudden. The error came because of some other guy was trying to delete records simultaneously without my knowledge and so the transaction got locked. After doing some Google search I could figure out the solution for it.

Here is what you have to do:

Just run “SHOW INNODB STATUS” in your query browser you will get the status of INNODB which contains LIST OF TRANSACTIONS FOR EACH SESSION. In that just find all the Active thread id’s, say you find one thread id = 148 and then just select and kill that thread id, like this: KILL 148.


That’s all you have to do.

Hope that helps.


Please leave your comments to help me improve my blog.
 
Thank You for visiting the Blog. Happy Coding! :)

No comments:

Post a Comment