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

Failed ALTER causes table corruption after recovery - Tablespace not found

    XMLWordPrintable

Details

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t (pk INT PRIMARY KEY) ENGINE=InnoDB;
      --error ER_ERROR_ON_RENAME
      ALTER TABLE t ADD FOREIGN KEY (pk) REFERENCES t (pk);
       
      CHECK TABLE t;
       
      --let $shutdown_timeout= 0
      --source include/restart_mysqld.inc
       
      CHECK TABLE t;
       
      # Cleanup
      DROP TABLE t;
      

      10.6 fdc4c3a2

      ALTER TABLE t ADD FOREIGN KEY (pk) REFERENCES t (pk);
      ERROR HY000: Error on rename of './test/#sql-alter-25dc40-4' to './test/t' (errno: 150 "Foreign key constraint is incorrectly formed")
      CHECK TABLE t;
      Table	Op	Msg_type	Msg_text
      test.t	check	status	OK
      # restart
      CHECK TABLE t;
      Table	Op	Msg_type	Msg_text
      test.t	check	Error	Unknown storage engine 'InnoDB'
      test.t	check	error	Corrupt
      DROP TABLE t;
      bug.recovery2 'innodb'                   [ fail ]  Found warnings/errors in server log file!
              Test ended at 2021-11-02 01:18:32
      line
      2021-11-02  1:18:32 4 [ERROR] InnoDB: In ALTER TABLE `test`.`t` has or is referenced in foreign key constraints which are not compatible with the new table definition.
      2021-11-02  1:18:32 0 [ERROR] InnoDB: Tablespace 5 was not found at ./test/t.ibd.
      2021-11-02  1:18:32 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace.
      2021-11-02  1:18:32 0 [ERROR] InnoDB: Plugin initialization aborted at srv0start.cc[1447] with error Tablespace not found
      2021-11-02  1:18:32 0 [ERROR] Plugin 'InnoDB' init function returned error.
      2021-11-02  1:18:32 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
      ^ Found warnings in /mnt-hd8t/bld/10.6-debug-nightly/mysql-test/var/log/mysqld.1.err
      

      So, after the failed ALTER the table still appears to be all right, but further crash recovery complains about a missing tablespace.

      Reproducible on 10.6 (including 10.6.4), 10.7. Not reproducible on 10.5.
      Reproducible every time for me, but since it's crash recovery imitated via MTR, it can well be non-deterministic.

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.