summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2023-03-23 16:29:21 +0300
committerNikita Malyavin <nikitamalyavin@gmail.com>2023-03-23 16:29:21 +0300
commitc16b2429f02c0acca6df068858fd1654fc0fa88b (patch)
tree6ee8c726915ad4c00f2a256ba56ac3b3e673c6e5
parentd8c908bb3996269b3b2cdb20bacac66ec1c3a2fa (diff)
downloadmariadb-git-bb-10.10-MDEV-16440.tar.gz
wake up from sleepbb-10.10-MDEV-16440
-rw-r--r--mysql-test/suite/perfschema/r/variables_by_thread.result15
-rw-r--r--mysql-test/suite/perfschema/t/variables_by_thread.test13
-rw-r--r--sql/item_func.cc3
3 files changed, 30 insertions, 1 deletions
diff --git a/mysql-test/suite/perfschema/r/variables_by_thread.result b/mysql-test/suite/perfschema/r/variables_by_thread.result
index afb4976eb20..133b1c2642d 100644
--- a/mysql-test/suite/perfschema/r/variables_by_thread.result
+++ b/mysql-test/suite/perfschema/r/variables_by_thread.result
@@ -147,6 +147,21 @@ WHERE variable_name = "time_zone";
current variable_value
1 +02:00
0 SYSTEM
+# Test sleep
+connect con_sleep, localhost, root,,;
+set debug_sync= "func_sleep_locked SIGNAL lock WAIT_FOR goon";
+select sleep(3);
+connection default;
+set debug_sync= "now WAIT_FOR lock";
+set debug_sync= "apc_after_notify SIGNAL goon";
+SELECT thread_id = @def_thread_id as current, variable_value
+FROM performance_schema.variables_by_thread
+WHERE variable_name = "time_zone";
+current variable_value
+1 +02:00
+0 SYSTEM
+0 SYSTEM
+disconnect con_sleep;
# Cleanup
connection default;
set debug_sync= "reset";
diff --git a/mysql-test/suite/perfschema/t/variables_by_thread.test b/mysql-test/suite/perfschema/t/variables_by_thread.test
index e63b3363fa4..b670fb58031 100644
--- a/mysql-test/suite/perfschema/t/variables_by_thread.test
+++ b/mysql-test/suite/perfschema/t/variables_by_thread.test
@@ -149,6 +149,19 @@ SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
+--echo # Test sleep
+
+--connect (con_sleep, localhost, root,,)
+set debug_sync= "func_sleep_locked SIGNAL lock WAIT_FOR goon";
+send select sleep(3);
+
+--connection default
+set debug_sync= "now WAIT_FOR lock";
+set debug_sync= "apc_after_notify SIGNAL goon";
+SELECT thread_id = @def_thread_id as current, variable_value
+ FROM performance_schema.variables_by_thread
+ WHERE variable_name = "time_zone";
+--disconnect con_sleep
--echo # Cleanup
--connection default
diff --git a/sql/item_func.cc b/sql/item_func.cc
index e53b89a9291..e2f737e9104 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4584,13 +4584,14 @@ longlong Item_func_sleep::val_int()
mysql_cond_init(key_item_func_sleep_cond, &cond, NULL);
mysql_mutex_lock(&LOCK_item_func_sleep);
+ DEBUG_SYNC(thd, "func_sleep_locked");
THD_STAGE_INFO(thd, stage_user_sleep);
thd->mysys_var->current_mutex= &LOCK_item_func_sleep;
thd->mysys_var->current_cond= &cond;
error= 0;
thd_wait_begin(thd, THD_WAIT_SLEEP);
- while (!thd->killed)
+ while (!thd->check_killed(true))
{
error= timed_cond.wait(&cond, &LOCK_item_func_sleep);
if (error == ETIMEDOUT || error == ETIME)