Commit 63cbb982 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14587 dict_stats_process_entry_from_defrag_pool() fails to call...

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.
parent d7b0b8dd
......@@ -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);
......
......@@ -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);
......
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