summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-05-10 18:36:13 +0300
committerOleksandr Byelkin <sanja@mariadb.com>2022-10-20 10:30:34 +0200
commit99e14aa5922666842175bf9bad180f5803ed9956 (patch)
treee50a2419ae8ad8401bd7a9101803f23318f7c563
parent81ad6787cc0a6df59e1115e307a2429daa11e079 (diff)
downloadmariadb-git-99e14aa5922666842175bf9bad180f5803ed9956.tar.gz
MDEV-25606: Concurrent CREATE TRIGGER statements mix up in binlog and break replication
The bug is that we don't have a a lock on the trigger name, so it is possible for two threads to try to create the same trigger at the same time and both thinks that they have succeed. Same thing can happen with drop trigger or a combinations of create and drop trigger. Fixed by adding a mdl lock for the trigger name for the duration of the create/drop.
-rw-r--r--sql/sql_trigger.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 501d3fc8841..6dead4fef16 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -471,7 +471,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
}
/* Protect against concurrent create/drop */
- MDL_REQUEST_INIT(&mdl_request_for_trn, MDL_key::TABLE,
+ MDL_REQUEST_INIT(&mdl_request_for_trn, MDL_key::TRIGGER,
create ? tables->db.str : thd->lex->spname->m_db.str,
thd->lex->spname->m_name.str,
MDL_EXCLUSIVE, MDL_EXPLICIT);