Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-37965

MDL conflict between CREATE TRIGGER and INSERT

    XMLWordPrintable

Details

    • Can result in hang or crash
    • Q4/2025 Galera Development

    Description

      In a Galera cluster a CREATE TRIGGER execution can have a MDL conflict with a replicated INSERT execution, if INSERT and CREATE happen on separate tables having foreign key constraint, e.g. like this:

      CREATE TABLE parent ( id INT PRIMARY KEY) ENGINE=InnoDB;
      CREATE TABLE child (id INT PRIMARY KEY, parent1_id INT,FOREIGN KEY (parent_id) REFERENCES parent(id)) ENGINE=InnoDB;
       
      then two sessions, connected in separate nodes;
      node1>  insert into parent1 values (1)
      node2>  CREATE TRIGGER trg BEFORE UPDATE ON child FOR EACH ROW BEGIN END;
      

      CREATE TRIGGER execution appears to take MDL lock on the parent table, but only in the primary node, in secondary node, the replication does not use MDL lock on parent table. Therefore the INSERT and CREATE TRIGGER have to happen in separate nodes.

      Attachments

        Activity

          People

            hemantdangi Hemant Dangi
            seppo Seppo Jaakola
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: