diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-12-05 13:25:09 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-12-05 13:25:09 +0200 |
commit | 63cbb982752eda34c8025c6daea9e4d2389807d0 (patch) | |
tree | 85f9329c6a5533d64b6aa0c4493f848a4a86778d | |
parent | d7b0b8ddacd6a27e0ea1c5fbad75aae60ed03d6b (diff) | |
download | mariadb-git-63cbb982752eda34c8025c6daea9e4d2389807d0.tar.gz |
MDEV-14587 dict_stats_process_entry_from_defrag_pool() fails to call dict_table_close() when index==NULL
dict_stats_process_entry_from_defrag_pool(): Simplify the logic,
and always call dict_table_close() when dict_table_open() returned
a non-NULL handle.
-rw-r--r-- | storage/innobase/dict/dict0stats_bg.cc | 28 | ||||
-rw-r--r-- | storage/xtradb/dict/dict0stats_bg.cc | 28 |
2 files changed, 14 insertions, 42 deletions
diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 43ee1a236ce..1c599136a6d 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -478,7 +478,6 @@ stats and eventually save its stats. */ static void dict_stats_process_entry_from_defrag_pool() -/*=======================================*/ { table_id_t table_id; index_id_t index_id; @@ -500,30 +499,17 @@ dict_stats_process_entry_from_defrag_pool() table = dict_table_open_on_id(table_id, TRUE, DICT_TABLE_OP_OPEN_ONLY_IF_CACHED); - if (table == NULL) { - mutex_exit(&dict_sys->mutex); - return; - } + dict_index_t* index = table && !table->corrupted + ? dict_table_find_index_on_id(table, index_id) + : NULL; - /* Check whether table is corrupted */ - if (table->corrupted) { - dict_table_close(table, TRUE, FALSE); + if (!index || dict_index_is_corrupted(index)) { + if (table) { + dict_table_close(table, TRUE, FALSE); + } mutex_exit(&dict_sys->mutex); return; } - mutex_exit(&dict_sys->mutex); - - dict_index_t* index = dict_table_find_index_on_id(table, index_id); - - if (index == NULL) { - return; - } - - /* Check whether index is corrupted */ - if (dict_index_is_corrupted(index)) { - dict_table_close(table, FALSE, FALSE); - return; - } dict_stats_save_defrag_stats(index); dict_table_close(table, FALSE, FALSE); diff --git a/storage/xtradb/dict/dict0stats_bg.cc b/storage/xtradb/dict/dict0stats_bg.cc index ba6fd115551..e2e7ad827b6 100644 --- a/storage/xtradb/dict/dict0stats_bg.cc +++ b/storage/xtradb/dict/dict0stats_bg.cc @@ -479,7 +479,6 @@ stats and eventually save its stats. */ static void dict_stats_process_entry_from_defrag_pool() -/*=======================================*/ { table_id_t table_id; index_id_t index_id; @@ -501,30 +500,17 @@ dict_stats_process_entry_from_defrag_pool() table = dict_table_open_on_id(table_id, TRUE, DICT_TABLE_OP_OPEN_ONLY_IF_CACHED); - if (table == NULL) { - mutex_exit(&dict_sys->mutex); - return; - } + dict_index_t* index = table && !table->corrupted + ? dict_table_find_index_on_id(table, index_id) + : NULL; - /* Check whether table is corrupted */ - if (table->corrupted) { - dict_table_close(table, TRUE, FALSE); + if (!index || dict_index_is_corrupted(index)) { + if (table) { + dict_table_close(table, TRUE, FALSE); + } mutex_exit(&dict_sys->mutex); return; } - mutex_exit(&dict_sys->mutex); - - dict_index_t* index = dict_table_find_index_on_id(table, index_id); - - if (index == NULL) { - return; - } - - /* Check whether index is corrupted */ - if (dict_index_is_corrupted(index)) { - dict_table_close(table, FALSE, FALSE); - return; - } dict_stats_save_defrag_stats(index); dict_table_close(table, FALSE, FALSE); |