[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 <knielsen@knielsen-hq.org> --- sql/rpl_parallel.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index b5e1bb96c1e..4d3f12e4116 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -551,6 +551,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 @@ -567,24 +568,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) - { - 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 (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); -- 2.39.5
participants (1)
-
Kristian Nielsen