Bug #79838 KILL QUERY has unexpected outcome if the connection finished a query
Submitted: 4 Jan 2016 20:19 Modified: 17 Feb 2016 11:57
Reporter: Dillon Sadofsky Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:5.1/5.5/5.6 OS:Any
Assigned to: CPU Architecture:Any
Tags: KILL

[4 Jan 2016 20:19] Dillon Sadofsky
Description:
I recently discovered that if a KILL QUERY operation executes (successfully) against a connection, but that connection is not currently running a query (possibly because execution finished on the query that was being killed) then the NEXT query that connection runs will be killed.  This throws the (normal) query execution interrupted error.

This is not described in the documentation (http://dev.mysql.com/doc/refman/5.6/en/kill.html).  It is implied that the current query (if any) will be killed, not any future queries.

Background:
When a user wishes to cancel a search in our software, a second connection is launched to run KILL QUERY on the first connection.  However, if the timing is wrong, the search finishes, then the KILL runs successfully, then the next query the application runs gets interrupted, which is not desirable.

How to repeat:
1. Open two connections, get the connection id for both with SHOW FULL PROCESSLIST or SELECT CONNECTION_ID().

2. In connection 1, run KILL QUERY <connection_2_id>;

3. In connection 2, run any query.  Mysql error 1317 will be reported.

Suggested fix:
If you run KILL QUERY on a connection not currently performing any query, it should simply do nothing.

If the devs feel this is an 'error state', then the error should be reported in the connection running KILL QUERY, not the one running a random query.

I can see how someone could think that KILL QUERY should do something if nothing is running, but I feel the way it currently works is not only undocumented, but also comes across as non-deterministic since another thread can put the thread into a state where a query will have an error an indeterminate amount of time in the future.
[4 Jan 2016 22:12] MySQL Verification Team
Server version 5.6

Attachment: kill_query_5_6.png (image/png, text), 80.65 KiB.

[4 Jan 2016 22:13] MySQL Verification Team
Server version 5.7

Attachment: kill_query_5_7.png (image/png, text), 71.44 KiB.

[4 Jan 2016 22:16] MySQL Verification Team
Thank you for the bug report. Issue repeatable with server version 5.1/5.5/5.6 and NOT REPEATABLE with server version 5.0 and 5.7.
[17 Feb 2016 11:57] Erlend Dahl
Duplicate of

Bug#45679 KILL QUERY not behaving consistently and will hang in some cases