Commit 0df51e61 authored by Monty's avatar Monty

MDEV-25651 Server crash or assertion failure in THD::update_stats upon concurrent DROP TRIGGER

The problem was that in a timeout event,
thd->lex->restore_backup_query_tables_list() was called when it should
not have been.

Patch tested with the script in MDEV-25651 (not suitable for mtr)
parent 621501f3
...@@ -396,6 +396,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) ...@@ -396,6 +396,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
bool result= TRUE; bool result= TRUE;
String stmt_query; String stmt_query;
bool lock_upgrade_done= FALSE; bool lock_upgrade_done= FALSE;
bool backup_of_table_list_done= 0;;
MDL_ticket *mdl_ticket= NULL; MDL_ticket *mdl_ticket= NULL;
MDL_request mdl_request_for_trn; MDL_request mdl_request_for_trn;
Query_tables_list backup; Query_tables_list backup;
...@@ -465,6 +466,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) ...@@ -465,6 +466,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
Protect the query table list from the temporary and potentially Protect the query table list from the temporary and potentially
destructive changes necessary to open the trigger's table. destructive changes necessary to open the trigger's table.
*/ */
backup_of_table_list_done= 1;
thd->lex->reset_n_backup_query_tables_list(&backup); thd->lex->reset_n_backup_query_tables_list(&backup);
/* /*
Restore Query_tables_list::sql_command, which was Restore Query_tables_list::sql_command, which was
...@@ -634,7 +636,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) ...@@ -634,7 +636,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE);
/* Restore the query table list. Used only for drop trigger. */ /* Restore the query table list. Used only for drop trigger. */
if (!create) if (backup_of_table_list_done)
thd->lex->restore_backup_query_tables_list(&backup); thd->lex->restore_backup_query_tables_list(&backup);
if (!result) if (!result)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment