Skip to content

Commit 63cbb98

Browse files
committed
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.
1 parent d7b0b8d commit 63cbb98

File tree

2 files changed

+14
-42
lines changed

2 files changed

+14
-42
lines changed

storage/innobase/dict/dict0stats_bg.cc

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ stats and eventually save its stats. */
478478
static
479479
void
480480
dict_stats_process_entry_from_defrag_pool()
481-
/*=======================================*/
482481
{
483482
table_id_ttable_id;
484483
index_id_tindex_id;
@@ -500,30 +499,17 @@ dict_stats_process_entry_from_defrag_pool()
500499
table = dict_table_open_on_id(table_id, TRUE,
501500
DICT_TABLE_OP_OPEN_ONLY_IF_CACHED);
502501

503-
if (table == NULL) {
504-
mutex_exit(&dict_sys->mutex);
505-
return;
506-
}
502+
dict_index_t* index = table && !table->corrupted
503+
? dict_table_find_index_on_id(table, index_id)
504+
: NULL;
507505

508-
/* Check whether table is corrupted */
509-
if (table->corrupted) {
510-
dict_table_close(table, TRUE, FALSE);
506+
if (!index || dict_index_is_corrupted(index)) {
507+
if (table) {
508+
dict_table_close(table, TRUE, FALSE);
509+
}
511510
mutex_exit(&dict_sys->mutex);
512511
return;
513512
}
514-
mutex_exit(&dict_sys->mutex);
515-
516-
dict_index_t* index = dict_table_find_index_on_id(table, index_id);
517-
518-
if (index == NULL) {
519-
return;
520-
}
521-
522-
/* Check whether index is corrupted */
523-
if (dict_index_is_corrupted(index)) {
524-
dict_table_close(table, FALSE, FALSE);
525-
return;
526-
}
527513

528514
dict_stats_save_defrag_stats(index);
529515
dict_table_close(table, FALSE, FALSE);

storage/xtradb/dict/dict0stats_bg.cc

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ stats and eventually save its stats. */
479479
static
480480
void
481481
dict_stats_process_entry_from_defrag_pool()
482-
/*=======================================*/
483482
{
484483
table_id_ttable_id;
485484
index_id_tindex_id;
@@ -501,30 +500,17 @@ dict_stats_process_entry_from_defrag_pool()
501500
table = dict_table_open_on_id(table_id, TRUE,
502501
DICT_TABLE_OP_OPEN_ONLY_IF_CACHED);
503502

504-
if (table == NULL) {
505-
mutex_exit(&dict_sys->mutex);
506-
return;
507-
}
503+
dict_index_t* index = table && !table->corrupted
504+
? dict_table_find_index_on_id(table, index_id)
505+
: NULL;
508506

509-
/* Check whether table is corrupted */
510-
if (table->corrupted) {
511-
dict_table_close(table, TRUE, FALSE);
507+
if (!index || dict_index_is_corrupted(index)) {
508+
if (table) {
509+
dict_table_close(table, TRUE, FALSE);
510+
}
512511
mutex_exit(&dict_sys->mutex);
513512
return;
514513
}
515-
mutex_exit(&dict_sys->mutex);
516-
517-
dict_index_t* index = dict_table_find_index_on_id(table, index_id);
518-
519-
if (index == NULL) {
520-
return;
521-
}
522-
523-
/* Check whether index is corrupted */
524-
if (dict_index_is_corrupted(index)) {
525-
dict_table_close(table, FALSE, FALSE);
526-
return;
527-
}
528514

529515
dict_stats_save_defrag_stats(index);
530516
dict_table_close(table, FALSE, FALSE);

0 commit comments

Comments
 (0)