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

server aborts after "Unknown error" is logged for FK key exceeding 3500

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.6(EOL), 10.11, 11.4
    • None
    • Galera, wsrep
    • None

    Description

      Generating a write set key for a foreign key can cause server abort If the normalized (collation weight) form of the key does not fit into the 3500 byte limited key buffer.
      Key generation returns DB_ERROR, which error handling does not recognise and turns into ib::fatal, killing the server.

      The condition is reached by ordinary multi column foreign keys on string columns whose collation expands during strnxfrm() the example schema below is within InnoDB's 3072 byte index length limit.

      The crash can be reproduced by three CHAR(255) columns in a UCA collation, as a composite primary key and foreign key. U+FB04 (the "ffl" ligature) normalizes to three collation weights, so each column contributes 1530 key bytes.

      CREATE TABLE p (a CHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
                      b CHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
                      c CHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
                      PRIMARY KEY (a,b,c)) ENGINE=InnoDB;
       
      CREATE TABLE ch (id INT AUTO_INCREMENT PRIMARY KEY,
                       a CHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
                       b CHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
                       c CHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
                       KEY k (a,b,c),
                       FOREIGN KEY (a,b,c) REFERENCES p (a,b,c)) ENGINE=InnoDB;
       
      SET @v = REPEAT(_utf8mb4 0xEFAC84, 255);
      INSERT INTO p VALUES (@v, @v, @v);
      INSERT INTO ch (a,b,c) VALUES (@v, @v, @v);   -- server aborts here
      

      Causing:

      WSREP: FK key len exceeded 3060 765 3500
      [ERROR] WSREP: FK key set failed: 11 (1reference), index: PRIMARY test/p, INSERT INTO ch (a,b,c) VALUES (...)
      [ERROR] [FATAL] InnoDB: Unknown error Generic error
      mariadbd got signal 6
      

      #6  ib::fatal::~fatal ()           storage/innobase/ut/ut0ut.cc:487
      #7  row_mysql_handle_errors ()     storage/innobase/row/row0mysql.cc:743
      #8  row_insert_for_mysql ()        storage/innobase/row/row0mysql.cc:1325
      #9  ha_innobase::write_row ()      storage/innobase/handler/ha_innodb.cc:7882
      #10 handler::ha_write_row ()       sql/handler.cc:7859
      #11 Write_record::single_insert () sql/sql_insert.cc:2327
      #13 mysql_insert ()                sql/sql_insert.cc:1217
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              seppo Seppo Jaakola
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 5d
                  5d
                  Remaining:
                  Remaining Estimate - 5d
                  5d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                  Git Integration

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