Commit dc82effa authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-25867 main.trigger-trans failed in bb, Assertion `ticket->m_duration ==...

MDEV-25867 main.trigger-trans failed in bb, Assertion `ticket->m_duration == MDL_EXPLICIT' failed in MDL_context::release_lock

release MDL on the trigger as early as possible, after everything that
cannot be done concurrently was done (under MDL), but before relocking
tables.
parent 78bd7d86
......@@ -393,7 +393,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
This is a good candidate for a minor refactoring.
*/
TABLE *table;
bool result= TRUE;
bool result= TRUE, refresh_metadata= FALSE;
String stmt_query;
bool lock_upgrade_done= FALSE;
bool backup_of_table_list_done= 0;;
......@@ -606,6 +606,17 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
table->triggers->create_trigger(thd, tables, &stmt_query):
table->triggers->drop_trigger(thd, tables, &stmt_query));
refresh_metadata= TRUE;
end:
if (!result)
result= write_bin_log(thd, TRUE, stmt_query.ptr(), stmt_query.length());
if (mdl_request_for_trn.ticket)
thd->mdl_context.release_lock(mdl_request_for_trn.ticket);
if (refresh_metadata)
{
close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL);
/*
......@@ -621,10 +632,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
pre-locking tables.
*/
sp_cache_invalidate();
end:
if (!result)
result= write_bin_log(thd, TRUE, stmt_query.ptr(), stmt_query.length());
}
/*
If we are under LOCK TABLES we should restore original state of
......@@ -647,14 +655,6 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
thd->lex->spname->m_name.str, static_cast<uint>(thd->lex->spname->m_name.length));
}
/* In Locked_tables_list::reopen_tables(),
MDL_context::set_transaction_duration_for_all_locks() may have been invoked,
converting our explicit MDL to transaction scope. In that case, we will not
release the lock, to avoid a debug assertion failure. */
if (MDL_ticket *ticket= mdl_request_for_trn.ticket)
if (thd->mdl_context.has_explicit_locks())
thd->mdl_context.release_lock(ticket);
DBUG_RETURN(result);
#ifdef WITH_WSREP
......
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