Question

I had a query, which I executed in Mysql workbench on my own computer, the database is on a remote computer.

After some time I got a 2013 error(Lost connection to MySQL server during query), there was no effect of the query. Later I tried some different queries and I always got a:

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

Does this mean that the query that I executed(during which the connection was lost) still has the table locked, if so how can I free the table. It has been three hours since the first query.

1205    admin_pw    BSN-176-177-215.dial-up.dsl.siol.net:9054   admin_pw    Query   11217   Sending data    DELETE n1 FROM mm_ads_fields_values n1, mm_ads_fields_values n2
WHERE n1.id < n2.id 
AND n1.aid = n2
1206    admin_pw    BSN-176-177-215.dial-up.dsl.siol.net:9100   admin_pw    Sleep   415     
1208    admin_pw    BSN-176-177-215.dial-up.dsl.siol.net:9281   admin_pw    Query   622 Locked  ALTER IGNORE TABLE mm_ads_fields_values ADD UNIQUE KEY idx1(aid,value)
1308    admin_pw    localhost       Sleep   30      
1309    admin_pw    BSN-176-177-215.dial-up.dsl.siol.net:16938  admin_pw    Query   0       show processlist

The output of show show processlist, the first query that got the 2013 error is the one with the id 1205.

Was it helpful?

Solution

Ok, using the output from show processlist you can see PID 1208 has your table locked. In a sandbox you could just kill everything and go back to work. But in real life you would want to kill the PID that has the lock and allow the remaining queries to then execute. Using the output above you would execute the following statement as root in MySQL

mysql> kill 1208;

Run this and then see if your other queries complete. If they do not and lock once again. Repeat the above procedure and then revisit your SQL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top