Commit c34deb4c authored by Kentoku SHIBA's avatar Kentoku SHIBA

fix memory calculate for spider_mon_table_cache

parent d3a6ed05
......@@ -850,6 +850,7 @@ int spider_init_ping_table_mon_cache(
bool need_lock
) {
int error_num, same;
uint old_elements;
TABLE *table_link_mon = NULL;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup;
......@@ -899,11 +900,23 @@ int spider_init_ping_table_mon_cache(
{
mon_key.sort = spider_calc_for_sort(3, mon_key.db_name,
mon_key.table_name, mon_key.link_id);
old_elements = spider_mon_table_cache.max_element;
if (push_dynamic(&spider_mon_table_cache, (uchar *) &mon_key))
{
error_num = HA_ERR_OUT_OF_MEM;
goto error_push_dynamic;
}
if (spider_mon_table_cache.max_element != old_elements)
{
spider_free_mem_calc(spider_current_trx,
spider_mon_table_cache_id,
old_elements *
spider_mon_table_cache.size_of_element);
spider_alloc_calc_mem(spider_current_trx,
spider_mon_table_cache,
spider_mon_table_cache.max_element *
spider_mon_table_cache.size_of_element);
}
}
if ((error_num = spider_sys_index_next(table_link_mon)))
......@@ -923,12 +936,16 @@ int spider_init_ping_table_mon_cache(
(uchar *) dynamic_element(&spider_mon_table_cache, 0, SPIDER_MON_KEY *),
spider_mon_table_cache.elements, sizeof(SPIDER_MON_KEY),
(qsort_cmp) spider_compare_for_sort);
uint old_elements = spider_mon_table_cache.max_element;
old_elements = spider_mon_table_cache.max_element;
freeze_size(&spider_mon_table_cache);
if (spider_mon_table_cache.max_element < old_elements)
if (spider_mon_table_cache.max_element != old_elements)
{
spider_free_mem_calc(spider_current_trx,
spider_mon_table_cache_id,
old_elements *
spider_mon_table_cache.size_of_element);
spider_alloc_calc_mem(spider_current_trx,
spider_mon_table_cache,
spider_mon_table_cache.max_element *
spider_mon_table_cache.size_of_element);
}
......
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