Commit 95bfde3d authored by thek@adventure.(none)'s avatar thek@adventure.(none)

Bug #32436 KILL QUERY completely deadlocks mysqld

Sending several "KILL QUERY" statements to target a connection running
"SELECT SLEEP" could freeze the server.

The locking order in Item_func_sleep was wrong and this could lead to a
dead lock.

This patch solves the issue by resolving the locking order properly.
parent 1794242b
...@@ -3732,13 +3732,12 @@ longlong Item_func_sleep::val_int() ...@@ -3732,13 +3732,12 @@ longlong Item_func_sleep::val_int()
break; break;
error= 0; error= 0;
} }
pthread_mutex_unlock(&LOCK_user_locks);
pthread_mutex_lock(&thd->mysys_var->mutex); pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0; thd->mysys_var->current_mutex= 0;
thd->mysys_var->current_cond= 0; thd->mysys_var->current_cond= 0;
pthread_mutex_unlock(&thd->mysys_var->mutex); pthread_mutex_unlock(&thd->mysys_var->mutex);
pthread_mutex_unlock(&LOCK_user_locks);
pthread_cond_destroy(&cond); pthread_cond_destroy(&cond);
return test(!error); // Return 1 killed return test(!error); // Return 1 killed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment