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

InnoDB: Failed to load table ... which has a foreign key constraint with ... after REPAIR + PARTITION BY on a table with an FK

    XMLWordPrintable

Details

    Description

      SET FOREIGN_KEY_CHECKS=0;
      CREATE TABLE t1 (c INT, FOREIGN KEY(c) REFERENCES t2(c));
      CREATE TABLE t2 (c BIGINT KEY);
      REPAIR TABLE t1;
      ALTER TABLE t1 PARTITION BY HASH(c);
      ALTER TABLE t2 FORCE;
      

      CLI Output: Warning/Error messages are printed only to the error log

      11.8.9-opt>SET FOREIGN_KEY_CHECKS=0;
      Query OK, 0 rows affected (0.000 sec)
       
      11.8.9-opt>CREATE TABLE t1 (c INT, FOREIGN KEY(c) REFERENCES t2(c));
      Query OK, 0 rows affected (0.012 sec)
       
      11.8.9-opt>CREATE TABLE t2 (c BIGINT KEY);
      Query OK, 0 rows affected (0.007 sec)
       
      11.8.9-opt>REPAIR TABLE t1;
      +---------+--------+----------+----------+
      | Table   | Op     | Msg_type | Msg_text |
      +---------+--------+----------+----------+
      | test.t1 | repair | status   | OK       |
      +---------+--------+----------+----------+
      1 row in set (0.015 sec)
       
      11.8.9-opt>ALTER TABLE t1 PARTITION BY HASH(c);
      Query OK, 0 rows affected (0.014 sec)
      Records: 0  Duplicates: 0  Warnings: 0
       
      11.8.9-opt>ALTER TABLE t2 FORCE;
      Query OK, 0 rows affected (0.010 sec)
      Records: 0  Duplicates: 0  Warnings: 0
       
      11.8.9-opt>
      

      Error log info

      2026-10-08 10:32:58 4 [Warning] InnoDB: In ALTER TABLE `test`.`t1` has or is referenced in foreign key constraints which are not compatible with the new table definition.
      2026-10-08 10:32:58 4 [ERROR] InnoDB: Failed to load table `test`.`t1` which has a foreign key constraint with`test`.`t2`
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed
      CS  10.11  dbg  061026  76ed5b7ea0c9cddfe9386aee4a5ff42a2adf1593  No bug found
      CS  10.11  opt  061026  76ed5b7ea0c9cddfe9386aee4a5ff42a2adf1593  No bug found
      CS  11.4   dbg  061026  b6398296aeeeb253bdb3d1dd1620d2bb03836bf7  No bug found
      CS  11.4   opt  061026  b6398296aeeeb253bdb3d1dd1620d2bb03836bf7  No bug found
      CS  11.8   dbg  061026  dddbd5ff427894941fee3d7528ca2058e026b82e  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      CS  11.8   opt  061026  dddbd5ff427894941fee3d7528ca2058e026b82e  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      CS  12.3   dbg  061026  07b869588831fb9ebc6364c77cba105d6cca3b77  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      CS  12.3   opt  061026  07b869588831fb9ebc6364c77cba105d6cca3b77  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      CS  13.0   dbg  061026  620a4b5624222048fece7fe1789978ae0675cae2  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      CS  13.0   opt  061026  620a4b5624222048fece7fe1789978ae0675cae2  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      CS  13.1   dbg  061026  87e62ca17270e163a6d41b3fc8d6f4d440f1bb88  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      CS  13.1   opt  061026  87e62ca17270e163a6d41b3fc8d6f4d440f1bb88  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      CS  13.2   dbg  061026  9d7ab2c0092df4bc73b64b915464aecf7e5fe6c4  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      CS  13.2   opt  061026  9d7ab2c0092df4bc73b64b915464aecf7e5fe6c4  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      ES  11.4   dbg  060526  90f707057d44f1b5c013a0c3672fd12f32ea7085  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      ES  11.4   opt  060526  90f707057d44f1b5c013a0c3672fd12f32ea7085  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      ES  11.8   dbg  060526  1499789de285a8109d68d79347de0281865b28f4  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      ES  11.8   opt  060526  1499789de285a8109d68d79347de0281865b28f4  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      ES  12.3   dbg  280926  082387a5f3cbb877157998bb4baa95928f4aa121  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      ES  12.3   opt  280926  082387a5f3cbb877157998bb4baa95928f4aa121  INNODB_ERROR|Failed to load table X.X which has a foreign key constraint withX.X
      

      Attachments

        Activity

          People

            tafzeel Mohammad Tafzeel Shams
            ramesh Ramesh Sivaraman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 0d
                0d
                Remaining:
                Time Spent - 0.5h Remaining Estimate - 3.5d
                3.5d
                Logged:
                Time Spent - 0.5h Remaining Estimate - 3.5d
                0.5h

                Git Integration

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