Commit 56c323c1 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-6728 KILL QUERY executed on an idle connection can interrupt the next query

reset KILL_QUERY when a new query execution is just about to be started
parent b4cd8a8a
......@@ -3,10 +3,12 @@ SHOW PROCESSLIST;
Id User Host db Command Time State Info Progress
# root # test Sleep # # NULL 0.000
# root # test Query # # SHOW PROCESSLIST 0.000
SET DEBUG_SYNC='before_execute_sql_command WAIT_FOR go';
SHOW PROCESSLIST;
connection default;
KILL QUERY con_id;
SET DEBUG_SYNC='now SIGNAL go';
connection con1;
SHOW PROCESSLIST;
ERROR 70100: Query execution was interrupted
SHOW PROCESSLIST;
Id User Host db Command Time State Info Progress
......
connect con1,localhost,root,,;
connection default;
kill query id;
connection con1;
select count(*) > 0 from mysql.user;
count(*) > 0
1
......@@ -1456,12 +1456,6 @@ GRANT PROCESS ON *.* TO test_u@localhost;
SHOW ENGINE MYISAM MUTEX;
SHOW ENGINE MYISAM STATUS;
DROP USER test_u@localhost;
#
# Bug #48985: show create table crashes if previous access to the table
# was killed
#
SHOW CREATE TABLE non_existent;
ERROR 70100: Query execution was interrupted
End of 5.1 tests
#
# Bug#52593 SHOW CREATE TABLE is blocked if table is locked
......
......@@ -2,16 +2,21 @@
# MDEV-6619 SHOW PROCESSLIST returns empty result set after KILL QUERY
#
--source include/not_embedded.inc
--source include/have_debug_sync.inc
--enable_connect_log
--connect (con1,localhost,root,,)
--let $con_id = `SELECT CONNECTION_ID()`
--replace_column 1 # 3 # 6 # 7 #
SHOW PROCESSLIST;
SET DEBUG_SYNC='before_execute_sql_command WAIT_FOR go';
send SHOW PROCESSLIST;
--connection default
--replace_result $con_id con_id
eval KILL QUERY $con_id;
SET DEBUG_SYNC='now SIGNAL go';
--connection con1
--error ER_QUERY_INTERRUPTED
SHOW PROCESSLIST;
reap;
--replace_column 1 # 3 # 6 # 7 #
SHOW PROCESSLIST;
#
# MDEV-6728 KILL QUERY executed on an idle connection can interrupt the next query
#
--enable_connect_log
--connect (con1,localhost,root,,)
let $id=`select connection_id()`;
--connection default
--replace_result $id id
eval kill query $id;
--connection con1
select count(*) > 0 from mysql.user;
......@@ -1210,33 +1210,8 @@ disconnect conn1;
connection default;
DROP USER test_u@localhost;
--echo #
--echo # Bug #48985: show create table crashes if previous access to the table
--echo # was killed
--echo #
connect(con1,localhost,root,,);
CONNECTION con1;
LET $ID= `SELECT connection_id()`;
CONNECTION default;
--disable_query_log
eval KILL QUERY $ID;
--enable_query_log
CONNECTION con1;
--error ER_QUERY_INTERRUPTED
SHOW CREATE TABLE non_existent;
DISCONNECT con1;
--source include/wait_until_disconnected.inc
CONNECTION default;
--echo End of 5.1 tests
--echo #
--echo # Bug#52593 SHOW CREATE TABLE is blocked if table is locked
--echo # for write by another connection
......
......@@ -374,6 +374,9 @@ CREATE VIEW v1 AS SELECT f1('a') FROM t1;
--send SELECT * FROM v1
--connection default
let $wait_condition=
select count(*) = 2 from information_schema.processlist where state = "User sleep";
--source include/wait_condition.inc
--disable_query_log
--eval KILL QUERY $ID_2
--eval KILL QUERY $ID_1
......
......@@ -3229,6 +3229,14 @@ public:
mysql_mutex_unlock(&LOCK_thd_data);
}
}
inline void reset_kill_query()
{
if (killed < KILL_CONNECTION)
{
reset_killed();
mysys_var->abort= 0;
}
}
inline void send_kill_message() const
{
int err= killed_errno();
......
......@@ -1124,6 +1124,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->enable_slow_log= TRUE;
thd->query_plan_flags= QPLAN_INIT;
thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
thd->reset_kill_query();
DEBUG_SYNC(thd,"dispatch_command_before_set_time");
......@@ -5111,11 +5112,7 @@ finish:
if (! thd->get_stmt_da()->is_set())
thd->send_kill_message();
}
if (thd->killed < KILL_CONNECTION)
{
thd->reset_killed();
thd->mysys_var->abort= 0;
}
thd->reset_kill_query();
}
if (thd->is_error() || (thd->variables.option_bits & OPTION_MASTER_SQL_ERROR))
trans_rollback_stmt(thd);
......
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