diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2017-07-21 16:05:20 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2017-07-21 16:05:20 +0300 |
commit | 92cbe388b6839bc1e21abb9859c54c58fc1769cf (patch) | |
tree | e34c5a03f82d2feba7ea91d0d7ca7bd6de0ceb92 /storage/innobase/dict/dict0dict.cc | |
parent | 0ec147b6174a8069c303a6d0bd4e3822fe16e4c2 (diff) | |
download | mariadb-git-92cbe388b6839bc1e21abb9859c54c58fc1769cf.tar.gz |
MDEV-13325: InnoDB assert dict_sys->size > 0 during ALTER TABLEbb-10.0-jan
Problem was that dict_sys->size tries to maintain used memory
occupied by the data dictionary table and index objects.
However at least on table objects table->heap size can increase
between when table object is inserted to dict_sys and when
it is removed from dict_sys causing inconsistency on amount
of memory added to and removed from dict_sys->size variable.
Removed unnecessary dict_sys:size variable as it is really
used only for status output.
Introduced dict_sys_get_size function to calculate memory
occupied by the data dictionary table and index objects
that is then used on show engine innodb output.
dict_table_add_to_cache(),
dict_table_rename_in_cache(),
dict_table_remove_from_cache_low(),
dict_index_remove_from_cache_low(),
Remove size calculation.
srv_printf_innodb_monitor(): Use dict_sys_get_size function to
get dictionary memory allocated.
xtradb_internal_hash_tables_fill_table(): Use dict_sys_get_size
function to get dictionary memory allocated.
Diffstat (limited to 'storage/innobase/dict/dict0dict.cc')
-rw-r--r-- | storage/innobase/dict/dict0dict.cc | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index b6ca02fa164..be19a3f1e75 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1365,9 +1365,6 @@ dict_table_add_to_cache( dict_table_autoinc_restore(table); ut_ad(dict_lru_validate()); - - dict_sys->size += mem_heap_get_size(table->heap) - + strlen(table->name) + 1; } /**********************************************************************//** @@ -1782,9 +1779,6 @@ dict_table_rename_in_cache( HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold, table); - dict_sys->size += strlen(new_name) - strlen(old_name); - ut_a(dict_sys->size > 0); - /* Update the table_name field in indexes */ for (index = dict_table_get_first_index(table); index != NULL; @@ -2071,7 +2065,6 @@ dict_table_remove_from_cache_low( { dict_foreign_t* foreign; dict_index_t* index; - ulint size; ut_ad(table); ut_ad(dict_lru_validate()); @@ -2151,12 +2144,6 @@ dict_table_remove_from_cache_low( trx_free_for_background(trx); } - size = mem_heap_get_size(table->heap) + strlen(table->name) + 1; - - ut_ad(dict_sys->size >= size); - - dict_sys->size -= size; - dict_mem_table_free(table); } @@ -2692,8 +2679,6 @@ undo_size_ok: dict_index_is_ibuf(index) ? SYNC_IBUF_INDEX_TREE : SYNC_INDEX_TREE); - dict_sys->size += mem_heap_get_size(new_index->heap); - dict_mem_index_free(index); return(DB_SUCCESS); @@ -2710,7 +2695,6 @@ dict_index_remove_from_cache_low( ibool lru_evict) /*!< in: TRUE if index being evicted to make room in the table LRU list */ { - ulint size; ulint retries = 0; btr_search_t* info; @@ -2778,12 +2762,6 @@ dict_index_remove_from_cache_low( /* Remove the index from the list of indexes of the table */ UT_LIST_REMOVE(indexes, table->indexes, index); - size = mem_heap_get_size(index->heap); - - ut_ad(dict_sys->size >= size); - - dict_sys->size -= size; - dict_mem_index_free(index); } @@ -7258,3 +7236,38 @@ dict_tf_to_row_format_string( return(0); } #endif /* !UNIV_HOTBACKUP */ + +/** Calculate the used memory occupied by the data dictionary +table and index objects. +@return number of bytes occupied. */ +UNIV_INTERN +ulint +dict_sys_get_size() +{ + ulint size = 0; + + ut_ad(dict_sys); + + mutex_enter(&dict_sys->mutex); + + for(ulint i = 0; i < hash_get_n_cells(dict_sys->table_hash); i++) { + dict_table_t* table; + + for (table = static_cast<dict_table_t*>(HASH_GET_FIRST(dict_sys->table_hash,i)); + table != NULL; + table = static_cast<dict_table_t*>(HASH_GET_NEXT(name_hash, table))) { + dict_index_t* index; + size += mem_heap_get_size(table->heap) + strlen(table->name) +1; + + for(index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + size += mem_heap_get_size(index->heap); + } + } + } + + mutex_exit(&dict_sys->mutex); + + return (size); +} |