diff options
author | Sergei Golubchik <serg@mariadb.org> | 2021-06-16 19:19:10 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-06-18 10:55:46 +0200 |
commit | dc82effa5df5e59be6c7de4038f0a832f37d9bdc (patch) | |
tree | a8bea4aac6f7c9c5ed9ae787ef6e97c6509d5893 /sql/sql_trigger.cc | |
parent | 78bd7d86a4a0b3733ba38373213645a6b3a9b9c6 (diff) | |
download | mariadb-git-dc82effa5df5e59be6c7de4038f0a832f37d9bdc.tar.gz |
MDEV-25867 main.trigger-trans failed in bb, Assertion `ticket->m_duration == MDL_EXPLICIT' failed in MDL_context::release_lockmariadb-10.5.11st-10.5-vicentiubb-10.5-vicentiu2
release MDL on the trigger as early as possible, after everything that
cannot be done concurrently was done (under MDL), but before relocking
tables.
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r-- | sql/sql_trigger.cc | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index a99078362d6..250ff859222 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -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,26 +606,34 @@ 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)); - close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL); - - /* - Reopen the table if we were under LOCK TABLES. - Ignore the return value for now. It's better to - keep master/slave in consistent state. - */ - if (thd->locked_tables_list.reopen_tables(thd, false)) - thd->clear_error(); - - /* - Invalidate SP-cache. That's needed because triggers may change list of - pre-locking tables. - */ - sp_cache_invalidate(); + 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); + + /* + Reopen the table if we were under LOCK TABLES. + Ignore the return value for now. It's better to + keep master/slave in consistent state. + */ + if (thd->locked_tables_list.reopen_tables(thd, false)) + thd->clear_error(); + + /* + Invalidate SP-cache. That's needed because triggers may change list of + pre-locking tables. + */ + sp_cache_invalidate(); + } + /* If we are under LOCK TABLES we should restore original state of meta-data locks. Otherwise all locks will be released along @@ -647,14 +655,6 @@ end: 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 |