From 8996fca8e2dcd9c2c7b8adfbfb65d102ca590877 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 18 Sep 2020 09:11:38 +0200 Subject: MDEV-23752 SHOW EXPLAIN FOR thd waits for sleep call check_killed() periodically during sleep() --- mysql-test/main/processlist_notembedded.result | 13 +++++++++++++ mysql-test/main/processlist_notembedded.test | 18 ++++++++++++++++++ sql/item_func.cc | 3 ++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/processlist_notembedded.result b/mysql-test/main/processlist_notembedded.result index b622fdf32b9..ab4d3f4d265 100644 --- a/mysql-test/main/processlist_notembedded.result +++ b/mysql-test/main/processlist_notembedded.result @@ -14,3 +14,16 @@ disconnect con1; connection default; SET DEBUG_SYNC = 'RESET'; End of 5.5 tests +# +# MDEV-23752: SHOW EXPLAIN FOR thd waits for sleep +# +connect con1,localhost,root,,; +select sleep(100000);; +connection default; +SHOW EXPLAIN FOR con_id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select sleep(100000) +KILL QUERY con_id; +# End of 10.6 tests diff --git a/mysql-test/main/processlist_notembedded.test b/mysql-test/main/processlist_notembedded.test index 6f269a816fc..3b1915eca64 100644 --- a/mysql-test/main/processlist_notembedded.test +++ b/mysql-test/main/processlist_notembedded.test @@ -40,3 +40,21 @@ SET DEBUG_SYNC = 'RESET'; source include/wait_until_count_sessions.inc; --echo End of 5.5 tests + +--echo # +--echo # MDEV-23752: SHOW EXPLAIN FOR thd waits for sleep +--echo # + +--connect (con1,localhost,root,,) +--let $con_id = `SELECT CONNECTION_ID()` +--send select sleep(100000); + +--connection default + +--replace_result $con_id con_id +eval SHOW EXPLAIN FOR $con_id; + +--replace_result $con_id con_id +eval KILL QUERY $con_id; + +--echo # End of 10.6 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 8a75d2c9946..8d00aac3463 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4020,7 +4020,8 @@ int Interruptible_wait::wait(mysql_cond_t *cond, mysql_mutex_t *mutex) if (error == ETIMEDOUT || error == ETIME) { /* Return error if timed out or connection is broken. */ - if (!cmp_timespec(timeout, m_abs_timeout) || !m_thd->is_connected()) + if (!cmp_timespec(timeout, m_abs_timeout) || !m_thd->is_connected() || + m_thd->check_killed(TRUE)) break; } /* Otherwise, propagate status to the caller. */ -- cgit v1.2.1