Commit 91a118d5 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Cleanup - reuse background THD in dict_stats_func()

Use static dict_stats_thd instead of creating/destroying it every time
function is called.
parent 8e6a476b
...@@ -373,15 +373,18 @@ static bool dict_stats_process_entry_from_recalc_pool(THD *thd) ...@@ -373,15 +373,18 @@ static bool dict_stats_process_entry_from_recalc_pool(THD *thd)
} }
static tpool::timer* dict_stats_timer; static tpool::timer* dict_stats_timer;
static THD *dict_stats_thd;
static void dict_stats_func(void*) static void dict_stats_func(void*)
{ {
THD *thd= innobase_create_background_thd("InnoDB statistics"); if (!dict_stats_thd)
set_current_thd(thd); dict_stats_thd= innobase_create_background_thd("InnoDB statistics");
while (dict_stats_process_entry_from_recalc_pool(thd)) {} set_current_thd(dict_stats_thd);
dict_defrag_process_entries_from_defrag_pool(thd);
while (dict_stats_process_entry_from_recalc_pool(dict_stats_thd)) {}
dict_defrag_process_entries_from_defrag_pool(dict_stats_thd);
innobase_reset_background_thd(dict_stats_thd);
set_current_thd(nullptr); set_current_thd(nullptr);
destroy_background_thd(thd);
} }
...@@ -408,4 +411,10 @@ void dict_stats_shutdown() ...@@ -408,4 +411,10 @@ void dict_stats_shutdown()
{ {
delete dict_stats_timer; delete dict_stats_timer;
dict_stats_timer= 0; dict_stats_timer= 0;
if (dict_stats_thd)
{
destroy_background_thd(dict_stats_thd);
dict_stats_thd= 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