From 7cc332b7240bdd78efce787cbd63a3f7073cda3b Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 21 Dec 2023 01:55:25 +0100 Subject: [PATCH] MDEV-33046 - delete unnecessary synchronization with dict_stats_mutex Timer has internal synchronization, so that calling set_time concurrently is not a problem. --- storage/innobase/dict/dict0stats_bg.cc | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 280c5c1dec8..c3b8c8798c0 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -411,7 +411,6 @@ next_table_id: } static tpool::timer* dict_stats_timer; -static std::mutex dict_stats_mutex; static void dict_stats_func(void*) { @@ -422,26 +421,15 @@ static void dict_stats_func(void*) void dict_stats_start() { - std::lock_guard lk(dict_stats_mutex); - if (!dict_stats_timer) - dict_stats_timer= srv_thread_pool->create_timer(dict_stats_func); + DBUG_ASSERT(!dict_stats_timer); + dict_stats_timer= srv_thread_pool->create_timer(dict_stats_func); } static void dict_stats_schedule(int ms) { - std::unique_lock lk(dict_stats_mutex, std::defer_lock); - /* - Use try_lock() to avoid deadlock in dict_stats_shutdown(), which - uses dict_stats_mutex too. If there is simultaneous timer reschedule, - the first one will win, which is fine. - */ - if (!lk.try_lock()) - { - return; - } - if (dict_stats_timer) - dict_stats_timer->set_time(ms,0); + DBUG_ASSERT(dict_stats_timer); + dict_stats_timer->set_time(ms,0); } void dict_stats_schedule_now() @@ -452,7 +440,6 @@ void dict_stats_schedule_now() /** Shut down the dict_stats_thread. */ void dict_stats_shutdown() { - std::lock_guard lk(dict_stats_mutex); delete dict_stats_timer; dict_stats_timer= 0; }