From ec002a11e771d607cbccedcaebeab02848d677ca Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Fri, 29 Nov 2024 10:58:05 +0100 Subject: [PATCH] MDEV-11176: FTWRL confusing state about "worker thread pool" The FLUSH TABLE WITH READ LOCK briefly set the state (in PROCESSLIST) to "Waiting while replication worker thread pool is busy", even if there was nothing to wait for. This is somewhat confusing on a server that might not even have any replication configured, let alone replication workers. Signed-off-by: Kristian Nielsen --- .../perfschema/r/stage_mdl_global.result | 1 - sql/rpl_parallel.cc | 29 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mysql-test/suite/perfschema/r/stage_mdl_global.result b/mysql-test/suite/perfschema/r/stage_mdl_global.result index 48aca9e5529..b72c3dd73f2 100644 --- a/mysql-test/suite/perfschema/r/stage_mdl_global.result +++ b/mysql-test/suite/perfschema/r/stage_mdl_global.result @@ -10,7 +10,6 @@ username event_name nesting_event_type username event_name nesting_event_type user1 stage/sql/starting STATEMENT user1 stage/sql/starting STATEMENT -user1 stage/sql/starting STATEMENT user1 stage/sql/Query end STATEMENT user1 stage/sql/closing tables STATEMENT user1 stage/sql/Query end STATEMENT diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 962c4f90c59..f02fa738971 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -552,6 +552,7 @@ pool_mark_busy(rpl_parallel_thread_pool *pool, THD *thd) { PSI_stage_info old_stage; int res= 0; + bool did_enter_cond= false; /* Wait here while the queue is busy. This is done to make FLUSH TABLES WITH @@ -568,24 +569,28 @@ pool_mark_busy(rpl_parallel_thread_pool *pool, THD *thd) */ DBUG_EXECUTE_IF("mark_busy_mdev_22370",my_sleep(1000000);); mysql_mutex_lock(&pool->LOCK_rpl_thread_pool); - if (thd) + if (pool->busy) { - thd->set_time_for_next_stage(); - thd->ENTER_COND(&pool->COND_rpl_thread_pool, &pool->LOCK_rpl_thread_pool, - &stage_waiting_for_rpl_thread_pool, &old_stage); - } - while (pool->busy) - { - if (thd && unlikely(thd->check_killed())) + if (thd) { - res= 1; - break; + thd->set_time_for_next_stage(); + thd->ENTER_COND(&pool->COND_rpl_thread_pool, &pool->LOCK_rpl_thread_pool, + &stage_waiting_for_rpl_thread_pool, &old_stage); + did_enter_cond= true; } - mysql_cond_wait(&pool->COND_rpl_thread_pool, &pool->LOCK_rpl_thread_pool); + do + { + if (thd && unlikely(thd->check_killed())) + { + res= 1; + break; + } + mysql_cond_wait(&pool->COND_rpl_thread_pool, &pool->LOCK_rpl_thread_pool); + } while (pool->busy); } if (!res) pool->busy= true; - if (thd) + if (did_enter_cond) thd->EXIT_COND(&old_stage); else mysql_mutex_unlock(&pool->LOCK_rpl_thread_pool);