Skip to content

Commit acf282c

Browse files
montywivuvova
authored andcommitted
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.
1 parent 79d9a72 commit acf282c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql/sql_trigger.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
475475
}
476476

477477
/* Protect against concurrent create/drop */
478-
MDL_REQUEST_INIT(&mdl_request_for_trn, MDL_key::TABLE,
478+
MDL_REQUEST_INIT(&mdl_request_for_trn, MDL_key::TRIGGER,
479479
create ? tables->db.str : thd->lex->spname->m_db.str,
480480
thd->lex->spname->m_name.str,
481481
MDL_EXCLUSIVE, MDL_EXPLICIT);

0 commit comments

Comments
 (0)