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

TRUNCATE on table with Foreign Key Constraint no longer replicated to other nodes

    XMLWordPrintable

Details

    Description

      When using the KB example for creating a table pair with a foreign key constraint:

      CREATE TABLE author (
        id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
        name VARCHAR(100) NOT NULL
      ) ENGINE = InnoDB;
       
      CREATE TABLE book (
        id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
        title VARCHAR(200) NOT NULL,
        author_id SMALLINT UNSIGNED NOT NULL,
        CONSTRAINT `fk_book_author`
          FOREIGN KEY (author_id) REFERENCES author (id)
          ON DELETE CASCADE
          ON UPDATE RESTRICT
      ) ENGINE = InnoDB;
       
      INSERT INTO author (name) VALUES ('Abdul Alhazred');
      INSERT INTO book (title, author_id) VALUES ('Necronomicon', LAST_INSERT_ID());
      

      Then truncating the "book" table:

      TRUNCATE TABLE book;
      

      The table is empty as expected on the node where the TRUNCATE was executed, but not on the other nodes in the cluster.

      Nothing is logged in the error log, it seems as if the TRUNCATE is just silently ignored.

      The earliest version I can reproduce this on is MariaDB 10.5.9, so it seems to be a rather recent regression, on earlier versions it works as expected.

      I filed this as "critical" as it can easily lead to data inconsistencies across the cluster which may only actually be detected, and lead to problems, much later.

      Attachments

        Issue Links

          Activity

            People

              jplindst Jan Lindström (Inactive)
              hholzgra Hartmut Holzgraefe
              Votes:
              3 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.