Bug #43353 When query is killed, error ER_QUERY_INTERRUPTED is not properly propagated
Submitted: 4 Mar 2009 8:48 Modified: 29 Jul 2012 23:34
Reporter: Zhenxing He Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S2 (Serious)
Version:5.0, 5.1, 6.0 bzr OS:Any
Assigned to: CPU Architecture:Any
Tags: disabled

[4 Mar 2009 8:48] Zhenxing He
Description:
When a query failed by killing, the error ER_QUERY_INTERRUPTED in some circumstances are not propagated to the upper level, and result in obscure error or even incorrect error. So when a query is killed, the error code can be something other than ER_QUERY_INTERRUPTED, which can confuse user and misleading.

For example:
--------------------------------------------------------------------------------------
connect (master, 127.0.0.1, root, , test, $MASTER_MYPORT);
connect (master1, 127.0.0.1, root, , test, $MASTER_MYPORT);

connection master1;
let $con_id= `select connection_id()`;

create function f1() returns int
  return 0;

send alter function f1 SQL SECURITY INVOKER;

connection master;
eval kill query $con_id;

connection master1;
reap;
--------------------------------------------------------------------------------------

Run this test case will mostly result in error ER_SP_CANT_ALTER, which is not quite clear about what happend. And sometimes if the killing happens while searching for the function, the error code can be ER_SP_DOES_NOT_EXIST, which is totally misleading.

This problem exists for some other DDL statements too, but I have not tested DML or other statements if they suffer this problem or not.

I think BUG#31807 probably is one instance of this problem.

How to repeat:
See description.

Suggested fix:
I think if the query was failed due to kill, the error code should always be ER_QUERY_INTERRUPTED, this error code should be propagated properly to upper level.
[4 Mar 2009 9:10] Sveta Smirnova
Thank you for the report.

Verified as described.
[29 Jul 2012 23:34] Paul DuBois
Noted in 5.6.6 changelog.

When a query was killed, the error code was not always properly
propagated up through the server code.