32 # include "dict0stats_bg.ic"
38 #define MIN_RECALC_INTERVAL 10
40 #define SHUTTING_DOWN() (srv_shutdown_state != SRV_SHUTDOWN_NONE)
47 #ifdef HAVE_PSI_INTERFACE
48 static mysql_pfs_key_t recalc_pool_mutex_key;
53 static const ulint RECALC_POOL_INITIAL_SLOTS = 128;
60 typedef recalc_pool_t::iterator recalc_pool_iterator_t;
66 dict_stats_recalc_pool_init()
71 recalc_pool.reserve(RECALC_POOL_INITIAL_SLOTS);
79 dict_stats_recalc_pool_deinit()
101 mutex_enter(&recalc_pool_mutex);
104 for (recalc_pool_iterator_t iter = recalc_pool.begin();
105 iter != recalc_pool.end();
108 if (*iter == table->
id) {
109 mutex_exit(&recalc_pool_mutex);
114 recalc_pool.push_back(table->
id);
116 mutex_exit(&recalc_pool_mutex);
127 dict_stats_recalc_pool_get(
134 mutex_enter(&recalc_pool_mutex);
136 if (recalc_pool.empty()) {
137 mutex_exit(&recalc_pool_mutex);
141 *
id = recalc_pool[0];
143 recalc_pool.erase(recalc_pool.begin());
145 mutex_exit(&recalc_pool_mutex);
162 mutex_enter(&recalc_pool_mutex);
166 for (recalc_pool_iterator_t iter = recalc_pool.begin();
167 iter != recalc_pool.end();
170 if (*iter == table->
id) {
172 recalc_pool.erase(iter);
177 mutex_exit(&recalc_pool_mutex);
227 mutex_create(recalc_pool_mutex_key, &recalc_pool_mutex,
228 SYNC_STATS_AUTO_RECALC);
230 dict_stats_recalc_pool_init();
242 ut_ad(!srv_dict_stats_thread_active);
244 dict_stats_recalc_pool_deinit();
246 mutex_free(&recalc_pool_mutex);
247 memset(&recalc_pool_mutex, 0x0,
sizeof(recalc_pool_mutex));
258 dict_stats_process_entry_from_recalc_pool()
266 if (!dict_stats_recalc_pool_get(&table_id)) {
330 extern "C" UNIV_INTERN
334 void* arg __attribute__((unused)))
339 srv_dict_stats_thread_active = TRUE;
341 while (!SHUTTING_DOWN()) {
351 if (SHUTTING_DOWN()) {
355 dict_stats_process_entry_from_recalc_pool();
360 srv_dict_stats_thread_active = FALSE;
366 OS_THREAD_DUMMY_RETURN;