Skip to content
Permalink
Browse files
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.
  • Loading branch information
dr-m committed Dec 5, 2017
1 parent d7b0b8d commit 63cbb98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 42 deletions.
@@ -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);

0 comments on commit 63cbb98

Please sign in to comment.