1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-12669 Circular foreign keys cause a loop and OOM upon LOCK TABLE

table_already_fk_prelocked() was looking for a table in the wrong
list (not the complete list of prelocked tables, but only in its tail,
starting from the current table - which is always empty for the last
added table), so for circular FKs it kept adding same tables to the list
indefinitely.

Backport of d6d7e169fb
This commit is contained in:
Sergei Golubchik
2018-07-18 19:04:51 +02:00
parent 710093ccb0
commit dd74332d2c
3 changed files with 47 additions and 2 deletions

View File

@ -4893,8 +4893,9 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
else
lock_type= TL_READ;
if (table_already_fk_prelocked(table_list, fk->foreign_db,
fk->foreign_table, lock_type))
if (table_already_fk_prelocked(prelocking_ctx->query_tables,
fk->foreign_db, fk->foreign_table,
lock_type))
continue;
TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));