From 9f40f02a8dda7f2becdc6e752557559e7835546d Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 22 Dec 2023 17:55:30 +0100 Subject: [PATCH] Fix galera.galera_kill_ddl test errors in debug mode. Marko reported DBUG_ASSERT from dict_stats_shutdown(). destroy_background_thd() does not like when current_thd is set. In galera, it can be the case, dict_stats_shutdown() can be called from user thread, to stop and later restart stats recalculations. --- storage/innobase/dict/dict0stats_bg.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 54378951b19..b0c34dc6d30 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -69,6 +69,8 @@ static recalc_pool_t recalc_pool; /** Whether the global data structures have been initialized */ static bool stats_initialised; +static THD *dict_stats_thd; + /*****************************************************************//** Free the resources occupied by the recalc pool, called once during thread de-initialization. */ @@ -90,6 +92,9 @@ static void dict_stats_recalc_pool_deinit() defrag_pool_t defrag_empty_pool; recalc_pool.swap(recalc_empty_pool); defrag_pool.swap(defrag_empty_pool); + + if (dict_stats_thd) + destroy_background_thd(dict_stats_thd); } /*****************************************************************//** @@ -379,7 +384,6 @@ static bool is_recalc_pool_empty() } static tpool::timer* dict_stats_timer; -static THD *dict_stats_thd; static void dict_stats_func(void*) { if (!dict_stats_thd) @@ -419,10 +423,4 @@ void dict_stats_shutdown() { delete dict_stats_timer; dict_stats_timer= 0; - - if (dict_stats_thd) - { - destroy_background_thd(dict_stats_thd); - dict_stats_thd= 0; - } }