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

"Incorrect key file for table" is produced instead of "No space left on device" when tmpdir gets full during operation on MyISAM table

    Details

      Description

      CREATE TEMPORARY TABLE tmp (a VARBINARY(45795)) ENGINE=MyISAM ROW_FORMAT FIXED;
       
      INSERT IGNORE INTO tmp VALUES
      ('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h'),('i'),('j'),('k'),('l'),
      ('m'),('n'),('o'),('p'),('q'),('r'),('s'),('t'),('u'),('v'),('w'),('x'),
      ('y'),('z'),('A'),('B'),('C'),('D'),('E'),('F'),('G'),('H'),('I'),('J'),
      ('K'),('L'),('M'),('N'),('O'),('P'),('Q'),('R'),('S'),('T'),('U'),('V'),
      ('W'),('X'),('Y'),('Z'),('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),
      ('8'),('9');
       
      SELECT * FROM tmp INTO OUTFILE 'load.data';
       
      --let $run= 1000
       
      while ($run)
      {
        LOAD DATA INFILE 'load.data' REPLACE INTO TABLE tmp;
        --dec $run
      }
       
      # If it did not fail before, it might fail here:
       
      ALTER TABLE tmp FORCE;
      

      If the test case above is run with --mysqld=--tmpdir=<some location with little space left>, then at some point it fails with

      mysqltest: At line 19: query 'LOAD DATA INFILE 'load.data' REPLACE INTO TABLE tmp' failed: 126: Incorrect key file for table '/smalldisk/tmp/mysqld.1/#sql5d91_3_0.MYI'; try to repair it
      

      The error log also contains the error, but nothing about disk space:

      2018-09-27 17:12:46 140302546643712 [ERROR] mysqld: Incorrect key file for table '/smalldisk/tmp/mysqld.1/#sql5d91_3_0.MYI'; try to repair it
      2018-09-27 17:12:46 140302546643712 [ERROR] Got an error from unknown thread, /data/src/10.1/storage/myisam/mi_write.c:227
      

      and the table remains corrupted afterwards:

      MariaDB [test]> check table tmp;
      +----------+-------+----------+---------------------------------------------------------------+
      | Table    | Op    | Msg_type | Msg_text                                                      |
      +----------+-------+----------+---------------------------------------------------------------+
      | test.tmp | check | warning  | Table is marked as crashed                                    |
      | test.tmp | check | error    | Size of datafile is: 1349070848         Should be: 1397205384 |
      | test.tmp | check | error    | Corrupt                                                       |
      +----------+-------+----------+---------------------------------------------------------------+
      3 rows in set (0.00 sec)
      

      The test attempts 1000 LOADs, and it's enough when I run it with tmpdir initially having 1G left. It can of course differ depending on the available disk space, so adjust accordingly.

      I've also seen it happen on ALTER TABLE.

      If the table is Aria, the test flow stops and waits for disk space to be freed, as expected:

      2018-09-27 16:36:40 140603029113600 [Warning] mysqld: Disk is full writing '/smalldisk/tmp/mysqld.1/#sql5125_3_0.MAD' (Errcode: 28 "No space left on device"). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
      2018-09-27 16:36:40 140603029113600 [Warning] mysqld: Retry in 60 secs. Message reprinted in 600 secs
      2018-09-27 16:37:40 140603029113600 [Warning] mysqld: Disk is full writing '/smalldisk/tmp/mysqld.1/#sql5125_3_0.MAD' (Errcode: 28 "No space left on device"). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
      2018-09-27 16:37:40 140603029113600 [Warning] mysqld: Retry in 60 secs. Message reprinted in 600 secs
      

      Reproducible on all of 5.5-10.4, and on MySQL 5.6/5.7 (didn't try 8.0). I don't know if the upstream bug report exists and didn't file one.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                elenst Elena Stepanova
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: