I have some problems with my server applications and it sometimes causes some tables to lock themselves and then I got thousands of queries waiting for the table being unlocked. But it won't happen. Is there any way to check what query could cause the lock?
You might use the
On the other hand, you're probably using MyISAM storage engine. If you don't need full text searches (or other MyISAM specific features), I'd recommend you to migrate to InnoDB, which provides row based locks instead of locking the entire table, among other features, which will probably improve the performance of your MySQL. Here's a nice comparison between MyISAM and InnoDB.
Possibly, you also need to tune some of your MySQL variables. I'd recommend you to tune
Last but not least, enable the slow query log. This will show which queries are taking too much time to run.
Hope this helps!