Commit 8e6a476b authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Merge branch '10.5' into 10.6

parents c1cc264f 569381df
...@@ -373,7 +373,6 @@ static bool dict_stats_process_entry_from_recalc_pool(THD *thd) ...@@ -373,7 +373,6 @@ static bool dict_stats_process_entry_from_recalc_pool(THD *thd)
} }
static tpool::timer* dict_stats_timer; static tpool::timer* dict_stats_timer;
static std::mutex dict_stats_mutex;
static void dict_stats_func(void*) static void dict_stats_func(void*)
{ {
...@@ -388,25 +387,14 @@ static void dict_stats_func(void*) ...@@ -388,25 +387,14 @@ static void dict_stats_func(void*)
void dict_stats_start() void dict_stats_start()
{ {
std::lock_guard<std::mutex> lk(dict_stats_mutex); DBUG_ASSERT(!dict_stats_timer);
if (!dict_stats_timer)
dict_stats_timer= srv_thread_pool->create_timer(dict_stats_func); dict_stats_timer= srv_thread_pool->create_timer(dict_stats_func);
} }
static void dict_stats_schedule(int ms) static void dict_stats_schedule(int ms)
{ {
std::unique_lock<std::mutex> lk(dict_stats_mutex, std::defer_lock); if(dict_stats_timer)
/*
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); dict_stats_timer->set_time(ms,0);
} }
...@@ -418,7 +406,6 @@ void dict_stats_schedule_now() ...@@ -418,7 +406,6 @@ void dict_stats_schedule_now()
/** Shut down the dict_stats_thread. */ /** Shut down the dict_stats_thread. */
void dict_stats_shutdown() void dict_stats_shutdown()
{ {
std::lock_guard<std::mutex> lk(dict_stats_mutex);
delete dict_stats_timer; delete dict_stats_timer;
dict_stats_timer= 0; dict_stats_timer= 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment