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

Certain compressed tables with myisampack are corrupted by "CHECK TABLE"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.14, 5.3.12, 5.5.37, 10.0.11
    • Fix Version/s: 5.5.38, 10.0.12
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows, Linux

      Description

      Creating a certain table and populating it with some dummy data, then compressing that table with myisampack, and then issuing a CHECK TABLE command results in corrupting the table (tested in MariaDB 5.5.37).

      The same table and data does not get corrupted by CHECK TABLE in MySQL 5.5.37.

      Here is a reproducible test case (I pared it down as far as I could for now):

      create table `t1` (`id` varchar(15) DEFAULT NULL) ENGINE=MyISAM ROW_FORMAT=FIXED;
      insert into t1 values ('aaa'),('bbb'),('ccc'),('ddd'),('eee');
      insert into t1 (select * from t1);
      insert into t1 (select * from t1);
      insert into t1 (select * from t1);
      insert into t1 (select * from t1);
      
      ..\..\bin\myisampack t1
      ..\..\bin\myisamchk -rq t1
      ..\..\bin\mysqladmin -uroot -pmysql -P3314 flush-tables
      
      check table t1;
      # <-- corrupt!
      
      mysql> check table t1;
      +-----------+-------+----------+-----------------------------------------------------------------------+
      | Table     | Op    | Msg_type | Msg_text                                                              |
      +-----------+-------+----------+-----------------------------------------------------------------------+
      | packed.t1 | check | warning  | Record checksum is not the same as checksum stored in the index file  |
      | packed.t1 | check | error    | Corrupt                                                               |
      +-----------+-------+----------+-----------------------------------------------------------------------+
      
      mysql> check table t1;
      +-----------+-------+----------+-----------------------------------------------------------------------+
      | Table     | Op    | Msg_type | Msg_text                                                              |
      +-----------+-------+----------+-----------------------------------------------------------------------+
      | packed.t1 | check | warning  | Table is marked as crashed                                            |
      | packed.t1 | check | warning  | Record checksum is not the same as checksum stored in the index file  |
      | packed.t1 | check | error    | Corrupt                                                               |
      +-----------+-------+----------+-----------------------------------------------------------------------+
      

      I suspect the varchar and the row_format=fixed are involved somehow.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            I can reproduce it on the top of 5.5 tree (revno 4189), but only on a non-debug build (I built with cmake . && make).

            MTR test case:

            create table `t1` (`id` varchar(15) DEFAULT NULL) ENGINE=MyISAM ROW_FORMAT=FIXED;
            insert into t1 values ('aaa'),('bbb'),('ccc'),('ddd'),('eee');
            insert into t1 (select * from t1);
            insert into t1 (select * from t1);
            insert into t1 (select * from t1);
            insert into t1 (select * from t1);
            FLUSH TABLES;
            
            let $MYSQLD_DATADIR= `select @@datadir`;
            --disable_abort_on_error
            --exec $MYISAMPACK $MYSQLD_DATADIR/test/t1
            --exec $MYISAMCHK -rq $MYSQLD_DATADIR/test/t1
            --exec $MYSQLADMIN flush-tables
            --enable_abort_on_error
            
            CHECK TABLE t1;
            

            Please note that disable/enable abort can be removed, but then the test case will fail not on CHECK TABLE, but on myisamchk.

            Show
            elenst Elena Stepanova added a comment - I can reproduce it on the top of 5.5 tree (revno 4189), but only on a non-debug build (I built with cmake . && make). MTR test case: create table `t1` (`id` varchar(15) DEFAULT NULL) ENGINE=MyISAM ROW_FORMAT=FIXED; insert into t1 values ('aaa'),('bbb'),('ccc'),('ddd'),('eee'); insert into t1 ( select * from t1); insert into t1 ( select * from t1); insert into t1 ( select * from t1); insert into t1 ( select * from t1); FLUSH TABLES; let $MYSQLD_DATADIR= ` select @@datadir`; --disable_abort_on_error --exec $MYISAMPACK $MYSQLD_DATADIR/test/t1 --exec $MYISAMCHK -rq $MYSQLD_DATADIR/test/t1 --exec $MYSQLADMIN flush-tables --enable_abort_on_error CHECK TABLE t1; Please note that disable/enable abort can be removed, but then the test case will fail not on CHECK TABLE, but on myisamchk.
            Hide
            monty Michael Widenius added a comment -

            I was able to repeat this in the latest 5.5 MariaDB version.
            The issue was a bug in the way we try to keep MyISAM compatible with MySQL when there is no calculated checksum for the table.
            This bug affected compressed tables with fixed row length and NULL fields.
            The table was usable, but check table gave an error that it had the wrong checksum. After running check table, one could still access the table, but one would get a warning that the table was corrupted.

            This is now fixed and pushed into 5.5i

            Show
            monty Michael Widenius added a comment - I was able to repeat this in the latest 5.5 MariaDB version. The issue was a bug in the way we try to keep MyISAM compatible with MySQL when there is no calculated checksum for the table. This bug affected compressed tables with fixed row length and NULL fields. The table was usable, but check table gave an error that it had the wrong checksum. After running check table, one could still access the table, but one would get a warning that the table was corrupted. This is now fixed and pushed into 5.5i
            Hide
            monty Michael Widenius added a comment -

            Fixed and pushed

            Show
            monty Michael Widenius added a comment - Fixed and pushed

              People

              • Assignee:
                monty Michael Widenius
                Reporter:
                ccalender Chris Calender
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours
                  2h