From c16b2429f02c0acca6df068858fd1654fc0fa88b Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Thu, 23 Mar 2023 16:29:21 +0300 Subject: wake up from sleep --- mysql-test/suite/perfschema/r/variables_by_thread.result | 15 +++++++++++++++ mysql-test/suite/perfschema/t/variables_by_thread.test | 13 +++++++++++++ sql/item_func.cc | 3 ++- 3 files changed, 30 insertions(+), 1 deletion(-) 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) -- cgit v1.2.1