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

Wrong error message to ALTER TABLE ... ADD KEY ...

    XMLWordPrintable

Details

    Description

      Source:
      ---------
      MariaDB 10.2 commit 87af52d7dd733e71fc7a9e39b882a4fd44f41fec
      2018-04-16 compiled with debug

      My test

      SET GLOBAL SQL_MODE = 'traditional';
      SET GLOBAL wait_timeout = 45;
      SET GLOBAL lock_wait_timeout = 2;
      SET GLOBAL innodb_lock_wait_timeout = 1;
      CREATE TABLE t1 (col1 INT, col4 CHAR(100)) ENGINE = InnoDB ;
      

      Now four concurrent sessions start to run one SQL in a loop:
      Session 1 --- INSERT INTO t1 (col1,col4) VALUES (1,'a') , (1,'a') ;
      Session 2 --- ALTER TABLE t1 ADD UNIQUE KEY uidx ( col4 );
      Session 3 --- ALTER TABLE t1 ADD               KEY  idx ( col1 );
                           The session aborts immediate if hitting error 1702.
      Session 4 --- ALTER TABLE t1 DROP KEY idx;
      

      After some time (you might need several test runs)

      • the session 3 which runs ALTER TABLE t1 ADD KEY idx ( col1 )
        could harvest the server response ERROR HY000: Index uidx is corrupted
      • but the final checks after the four concurrent sessions have disconnected
        show that there is no Index uidx and no corruption at all.

         SHOW CREATE TABLE t1;
          Table   Create Table
           t1      CREATE TABLE `t1` (
           `col1` int(11) DEFAULT NULL,
           `col4` char(100) DEFAULT NULL
           ) ENGINE=InnoDB DEFAULT CHARSET=latin1
           SELECT * FROM t1 LIMIT 3;
           col1    col4
           1       a
           1       a
           1       a
           CHECK TABLE t1 EXTENDED;
           Table   Op      Msg_type        Msg_text
           test.t1 check   status  OK
           ANALYZE TABLE t1;
           Table   Op      Msg_type        Msg_text
            test.t1 analyze status  OK
        

      Protocols of the concurrent sessions:

      1 --- All INSERTS passed
      2 --- masses of ERROR 23000: Duplicate entry 'a' for key 'uidx'
      3 --- One ERROR HY000: Index uidx is corrupted
      4 --- masses of ERROR 42000: Can't DROP INDEX `idx`; check that it exists
      

      IMHO the bug itself isn't that important because

      • there is no obvious damage to the table or indexes
      • running concurrent DDL on the same table is extreme unlikely
        but the error message from the server is in two points ugly
        1. A user might assume that something around his table is rotten, get in panic
        and either waste time with DDL or restore backups in order to fix something
        or try the same, but make an error and introduce by that damages
        2. ALTER TABLE t1 ADD KEY idx ( col1 ) harvesting an error message
        referring to an index with different name (uidx) looks very strange.

      Attachments

        Activity

          People

            wlad Vladislav Vaintroub
            mleich Matthias Leich
            Votes:
            0 Vote for this issue
            Watchers:
            6 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.