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

Table corruption ER_NO_SUCH_TABLE_IN_ENGINE or ER_CRASHED_ON_USAGE after ALTER on table with foreign key

    XMLWordPrintable

Details

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)) ENGINE=InnoDB;
      ALTER TABLE t1 ADD FOREIGN KEY (b) REFERENCES t1 (a) ON UPDATE CASCADE;
      LOCK TABLE t1 WRITE;
      TRUNCATE TABLE t1;
      ALTER TABLE t1 ADD c INT;
       
      # Cleanup
      UNLOCK TABLES;
      DROP TABLE t1;
      

      10.2 51b7438d debug and non-debug alike

      mysqltest: At line 7: query 'ALTER TABLE t1 ADD c INT' failed: 1932: Table 'test.t1' doesn't exist in engine
      

      2021-01-06  1:44:39 140509058860800 [Warning] InnoDB: Table test/t1 contains 2 user defined columns in InnoDB, but 3 columns in MariaDB. Please check INFORMATION_SCHEMA.INNODB_SYS_COLUMNS and https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
      

      10.5 20727387 non-debug

      mysqltest: At line 7: query 'ALTER TABLE t1 ADD c INT' failed: 1194: Table 't1' is marked as crashed and should be repaired
      

      2021-01-06  1:45:53 4 [Warning] InnoDB: Table test/t1 contains 2 user defined columns in InnoDB, but 3 columns in MariaDB. Please check INFORMATION_SCHEMA.INNODB_SYS_COLUMNS and https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
      2021-01-06  1:45:53 4 [ERROR] mariadbd: Table 't1' is marked as crashed and should be repaired
      

      10.5 20727387 debug

      2021-01-06  1:46:48 4 [Warning] InnoDB: Table test/t1 contains 2 user defined columns in InnoDB, but 3 columns in MariaDB. Please check INFORMATION_SCHEMA.INNODB_SYS_COLUMNS and https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
      2021-01-06  1:46:48 4 [ERROR] mariadbd: Table 't1' is marked as crashed and should be repaired
      mariadbd: /data/src/10.5/sql/sql_base.cc:2375: int Locked_tables_list::unlock_locked_tables(THD*): Assertion `thd->transaction->stmt.is_empty()' failed.
      210106  1:46:48 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007fe54d198f36 in __GI___assert_fail (assertion=0x56169620e3c0 "thd->transaction->stmt.is_empty()", file=0x56169620d7c0 "/data/src/10.5/sql/sql_base.cc", line=2375, function=0x56169620e388 "int Locked_tables_list::unlock_locked_tables(THD*)") at assert.c:101
      #8  0x00005616953ab046 in Locked_tables_list::unlock_locked_tables (this=0x7fe510004d90, thd=0x7fe510000db8) at /data/src/10.5/sql/sql_base.cc:2375
      #9  0x00005616953ab4b6 in Locked_tables_list::unlink_all_closed_tables (this=0x7fe510004d90, thd=0x7fe510000db8, lock=0x0, reopen_count=0) at /data/src/10.5/sql/sql_base.cc:2557
      #10 0x00005616953aba61 in Locked_tables_list::reopen_tables (this=0x7fe510004d90, thd=0x7fe510000db8, need_reopen=false) at /data/src/10.5/sql/sql_base.cc:2654
      #11 0x0000561695561cfc in mysql_alter_table (thd=0x7fe510000db8, new_db=0x7fe510005800, new_name=0x7fe510005c00, create_info=0x7fe548142420, table_list=0x7fe510014010, alter_info=0x7fe548142350, order_num=0, order=0x0, ignore=false, if_exists=false) at /data/src/10.5/sql/sql_table.cc:11044
      #12 0x0000561695608adc in Sql_cmd_alter_table::execute (this=0x7fe5100147f8, thd=0x7fe510000db8) at /data/src/10.5/sql/sql_alter.cc:539
      #13 0x000056169545f9cc in mysql_execute_command (thd=0x7fe510000db8) at /data/src/10.5/sql/sql_parse.cc:6006
      #14 0x0000561695465d88 in mysql_parse (thd=0x7fe510000db8, rawbuf=0x7fe510013f30 "ALTER TABLE t1 ADD c INT", length=24, parser_state=0x7fe548143510, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:8042
      #15 0x0000561695451d6b in dispatch_command (command=COM_QUERY, thd=0x7fe510000db8, packet=0x7fe5100090a9 "ALTER TABLE t1 ADD c INT", packet_length=24, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1872
      #16 0x000056169545055f in do_command (thd=0x7fe510000db8) at /data/src/10.5/sql/sql_parse.cc:1353
      #17 0x00005616955fde9f in do_handle_one_connection (connect=0x5616984b58a8, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1410
      #18 0x00005616955fdc02 in handle_one_connection (arg=0x5616984cf308) at /data/src/10.5/sql/sql_connect.cc:1312
      #19 0x0000561695b5c74d in pfs_spawn_thread (arg=0x5616984b54e8) at /data/src/10.5/storage/perfschema/pfs.cc:2201
      #20 0x00007fe54d6b0609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #21 0x00007fe54d284293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Reproducible on 10.2-10.6 with slight differences as described above.
      Not reproducible on 10.1.
      Not reproducible on MySQL 5.7 or 8.0.

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.