// Create and populate dummy data (exact schema is not required, you can use your existing script here) create table t1 ( id int primary key, value int, value2 varchar(255), index(value, value2) )engine=innodb; 2. Generate 500k rows by the following perl script for(my $i=1; $i <= 500000; $i++) { my $txt = 'x' x 150; print "$i,$i,$txt\n"; } 3. Load the data into table load data local infile '...' into table t1 fields terminated by ','; // pls ignore the query as it doesn't make any sense and idea was to run something complex/messy to trigger the issue root@cluster-repo ~]# cat bug78809.c #include #include #include int main(int argc, char **argv) { MYSQL *mysql = NULL; mysql = mysql_init(mysql); if (!mysql) { puts("Init faild, out of memory?"); return EXIT_FAILURE; } if (!mysql_real_connect(mysql, "localhost", "root", "", "bug", 0, NULL, CLIENT_FOUND_ROWS /* connection flags */ )) { puts("Connect failed\n"); } else { if (mysql_query(mysql, "SELECT a.id from t1 as a inner join t1 as b on a.id<= 500000 inner join t1 as c on b.value<>c.id where b.value-c.value group by a.id")) { printf("Query failed: %s\n", mysql_error(mysql)); } else { MYSQL_RES *result = mysql_use_result(mysql); exit(1); if (result) { puts("Got a valid result set\n"); mysql_free_result(result); } else { printf("Couldn't get results set: %s\n", mysql_error(mysql)); } } } mysql_close(mysql); return EXIT_SUCCESS; } // session 1 // build then run (MySQL instance version checked 5.6.26/27/28) gcc bug78809.c -Wall -g -o bug78809 `mysql_config --libs_r` `mysql_config --include` [root@cluster-repo ~]# ./bug78809 Killed // session 2( kill the running script) and confirm that it is "killed" in session 1 [root@cluster-repo ~]# ps aux|grep bug78809 root 27612 0.0 0.0 26412 1980 pts/1 S+ 20:23 0:00 ./bug78809 root 27615 0.0 0.0 103356 836 pts/2 S+ 20:23 0:00 grep bug78809 [root@cluster-repo ~]# kill -9 27612 [root@cluster-repo ~]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 32 Server version: 5.6.26-log MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show processlist; +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | 31 | root | localhost | bug | Query | 10 | Sending data | SELECT a.id from t1 as a inner join t1 as b on a.id<= 500000 inner join t1 as c on b.value<>c.id whe | | 32 | root | localhost | NULL | Query | 0 | init | show processlist | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec) . . mysql> show processlist; +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | 31 | root | localhost | bug | Query | 64 | Sending data | SELECT a.id from t1 as a inner join t1 as b on a.id<= 500000 inner join t1 as c on b.value<>c.id whe | | 32 | root | localhost | NULL | Query | 0 | init | show processlist | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec) mysql> . mysql> show processlist; +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | 31 | root | localhost | bug | Query | 269 | Sending data | SELECT a.id from t1 as a inner join t1 as b on a.id<= 500000 inner join t1 as c on b.value<>c.id whe | | 32 | root | localhost | NULL | Query | 0 | init | show processlist | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec) . . mysql> show processlist; +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | 31 | root | localhost | bug | Query | 831 | Sending data | SELECT a.id from t1 as a inner join t1 as b on a.id<= 500000 inner join t1 as c on b.value<>c.id whe | | 32 | root | localhost | NULL | Query | 0 | init | show processlist | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec) . . mysql> show processlist; +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | 31 | root | localhost | bug | Query | 1359 | Sending data | SELECT a.id from t1 as a inner join t1 as b on a.id<= 500000 inner join t1 as c on b.value<>c.id whe | | 32 | root | localhost | NULL | Query | 0 | init | show processlist | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec) . mysql> show processlist; +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ | 31 | root | localhost | bug | Query | 2631 | Sending data | SELECT a.id from t1 as a inner join t1 as b on a.id<= 500000 inner join t1 as c on b.value<>c.id whe | | 32 | root | localhost | NULL | Query | 0 | init | show processlist | +----+------+-----------+------+---------+------+--------------+------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec) mysql>