From 315b60e885f2e9fa5242dbc62b5f69d536665edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 22 Oct 2025 09:25:18 +0300 Subject: [PATCH] MDEV-26599 Assertion `!table->id' failed in btr_search_lazy_free btr_search_lazy_free(): Check for !table->id. It is possible that dict_sys_t::remove(table, ...) has started executing but has not reached the final part yet. If that is the case, let dict_sys_t::remove() observe that table->freed_indexes is empty and let it free the table object. Reviewed by: Thirunarayanan Balathandayuthapani Tested by: Saahil Alam --- storage/innobase/btr/btr0sea.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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. */