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

Unexpected ER_GET_ERRNO upon ALTER on MyISAM table, crash in Locked_tables_list::mark_table_for_reopen as aftermath

    XMLWordPrintable

Details

    Description

      Note: The crash mentioned here looks very similar to MDEV-25052.
      However, there are major differences.
      First of all, the main complaint here is not the crash but the preceding ER_GET_ERRNO. I consider the crash being a secondary effect of a previous problem.
      Also, MDEV-25052 is said to affect InnoDB tables on 10.2. This issue, on the contrary, affects MyISAM tables on 10.3+ (and the crash happens on 10.3-10.4).

      Test case 1: ER_GET_ERRNO

      CREATE TABLE t1 (
        a int,
        b int,
        UNIQUE(a),
        UNIQUE(b),
        PRIMARY KEY(b)
      ) ENGINE=MyISAM;
       
      CREATE TABLE t2 (d INT);
       
      LOCK TABLE t1 WRITE, t2 WRITE;
       
      ALTER TABLE t1 DROP CONSTRAINT IF EXISTS xx;
      

      10.3 3157fa18

      mysqltest: At line 13: query 'ALTER TABLE t1 DROP CONSTRAINT IF EXISTS xx' failed: 1030: Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM
      

      This is unexpected. The constraint doesn't exist, and we run ALTER with IF EXISTS, so the expected result would be success with the usual warning ER_CANT_DROP_FIELD_OR_KEY.

      Reproducible on 10.3-10.6. Not reproducible on 10.2.

      If we allow the test to proceed by masking the error, we can get a crash on the next very valid ALTER:

      Test case 2: secondary crash

      CREATE TABLE t1 (
        a int,
        b int,
        UNIQUE(a),
        UNIQUE(b),
        PRIMARY KEY(b)
      ) ENGINE=MyISAM;
       
      CREATE TABLE t2 (d INT);
       
      LOCK TABLE t1 WRITE, t2 WRITE;
       
      --error ER_GET_ERRNO
      ALTER TABLE t1 DROP CONSTRAINT IF EXISTS xx;
       
      ALTER TABLE t2 CHANGE COLUMN d e INT;
       
      # Cleanup
      UNLOCK TABLES;
      DROP TABLE t1, t2;
      

      10.3 3157fa18

      #3  <signal handler called>
      #4  Locked_tables_list::mark_table_for_reopen (this=0x7f4aa4004aa0, thd=0x7f4aa4000d90, table=0x7f4aa403a0d0) at /data/src/10.3/sql/sql_base.cc:2489
      #5  0x000055b0e163a74a in TABLE::mark_table_for_reopen (this=0x7f4aa403a0d0) at /data/src/10.3/sql/table.cc:9388
      #6  0x000055b0e15eae9c in mysql_prepare_alter_table (thd=0x7f4aa4000d90, table=0x7f4aa403a0d0, create_info=0x7f4ab68b4530, alter_info=0x7f4ab68b4470, alter_ctx=0x7f4ab68b3940) at /data/src/10.3/sql/sql_table.cc:8104
      #7  0x000055b0e15efb4c in mysql_alter_table (thd=0x7f4aa4000d90, new_db=0x7f4aa4005478, new_name=0x7f4aa4005860, create_info=0x7f4ab68b4530, table_list=0x7f4aa4012bc8, alter_info=0x7f4ab68b4470, order_num=0, order=0x0, ignore=false) at /data/src/10.3/sql/sql_table.cc:9667
      #8  0x000055b0e1681192 in Sql_cmd_alter_table::execute (this=0x7f4aa4013348, thd=0x7f4aa4000d90) at /data/src/10.3/sql/sql_alter.cc:512
      #9  0x000055b0e150b88d in mysql_execute_command (thd=0x7f4aa4000d90) at /data/src/10.3/sql/sql_parse.cc:6078
      #10 0x000055b0e1510f42 in mysql_parse (thd=0x7f4aa4000d90, rawbuf=0x7f4aa4012ad8 "ALTER TABLE t2 CHANGE COLUMN d e INT", length=36, parser_state=0x7f4ab68b55c0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7871
      #11 0x000055b0e14fd5d6 in dispatch_command (command=COM_QUERY, thd=0x7f4aa4000d90, packet=0x7f4aa4008f31 "ALTER TABLE t2 CHANGE COLUMN d e INT", packet_length=36, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1852
      #12 0x000055b0e14fbf76 in do_command (thd=0x7f4aa4000d90) at /data/src/10.3/sql/sql_parse.cc:1398
      #13 0x000055b0e167b029 in do_handle_one_connection (connect=0x55b0e3823660) at /data/src/10.3/sql/sql_connect.cc:1403
      #14 0x000055b0e167ad85 in handle_one_connection (arg=0x55b0e3823660) at /data/src/10.3/sql/sql_connect.cc:1308
      #15 0x000055b0e204b737 in pfs_spawn_thread (arg=0x55b0e3806690) at /data/src/10.3/storage/perfschema/pfs.cc:1869
      #16 0x00007f4abcda1609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #17 0x00007f4abc97b293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Reproducible on 10.3-10.4, debug and release builds alike. 10.5 doesn't crash and doesn't return ASAN errors, even though the preceding ER_GET_ERRNO is still there.

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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