MDEV-33167 ASAN errors in dict_sys_t::load_table / get_foreign_key_info after failing to load a table

Problem:
=======
- While loading the foreign key constraints for the parent table,
if child table wasn't open then InnoDB uses the parent table heap
to store the child table name in fk_tables list. If the consecutive
foreign key relation for the parent table fails with error,
InnoDB evicts the parent table from memory. But InnoDB accesses the
evicted table memory again in dict_sys.load_table()

Solution:
========
dict_load_table_one(): In case of error, remove the child table
names which was added during dict_load_foreigns()
This commit is contained in:
Thirunarayanan Balathandayuthapani 2025-04-03 16:43:01 +05:30
commit b11772d9a5
3 changed files with 47 additions and 6 deletions

View file

@ -2515,10 +2515,12 @@ corrupted:
if (!table->is_readable()) {
/* Don't attempt to load the indexes from disk. */
} else if (err == DB_SUCCESS) {
auto i = fk_tables.size();
err = dict_load_foreigns(table->name.m_name, nullptr,
0, true, ignore_err, fk_tables);
if (err != DB_SUCCESS) {
fk_tables.erase(fk_tables.begin() + i, fk_tables.end());
ib::warn() << "Load table " << table->name
<< " failed, the table has missing"
" foreign key indexes. Turn off"