diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index 04a278dce05..ecec0331573 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -205,18 +205,16 @@ ATTRIBUTE_COLD static void btr_search_lazy_free(dict_index_t *index) UT_LIST_REMOVE(table->freed_indexes, index); index->lock.free(); dict_mem_index_free(index); + const bool destroy= !table->id && !UT_LIST_GET_LEN(table->freed_indexes) && + !UT_LIST_GET_LEN(table->indexes); + table->autoinc_mutex.wr_unlock(); - if (!UT_LIST_GET_LEN(table->freed_indexes) && - !UT_LIST_GET_LEN(table->indexes)) + if (destroy) { - ut_ad(!table->id); - table->autoinc_mutex.wr_unlock(); table->autoinc_mutex.destroy(); dict_mem_table_free(table); return; } - - table->autoinc_mutex.wr_unlock(); } /** Disable the adaptive hash search system and empty the index. */