Bug #5625 | MyISAM Index corruption on ALTER TABLE x ENABLE KEYS due to full tmpdir | ||
---|---|---|---|
Submitted: | 17 Sep 2004 9:38 | Modified: | 14 Oct 2004 18:41 |
Reporter: | Hartmut Holzgraefe | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: MyISAM storage engine | Severity: | S1 (Critical) |
Version: | 4.0.20 | OS: | Windows (Windows, Linux) |
Assigned to: | Ingo Strüwing | CPU Architecture: | Any |
[17 Sep 2004 9:38]
Hartmut Holzgraefe
[20 Sep 2004 17:25]
Ingo Strüwing
I cannot repeat this on Linux. I get correct messages: ERROR 1030 at line 1: Got error 28 from table handler (which is "No space left on device").
[23 Sep 2004 8:52]
Hartmut Holzgraefe
i didn't test this on Linux but it definetly happens on Windows i was able to reproduce it on my box (XP SP2) the way the customer reported
[7 Oct 2004 9:49]
Hartmut Holzgraefe
Step by Step guide: - change your my.ini configuration so that tmpdir is on a floppy drive [mysqld] ... tmpdir=A:/ ... - restart the server, make sure it uses the right configuration SHOW VARIABLES LIKE 'tmpdir'; - create a source table with about 10 millon rows CREATE i1 (i int); ... fill with data, about 10 million random integers- ... i can't attach my sample table here, it exceeds the upload limit - create a 2nd table CREATE i2 (i int, key(i)); - - disable keys on this table ALTER TABLE i2 DISABLE keys - fill the 2nd table with data INSERT INTO i2 SELECT i FROM i1;- - now enable keys on the new table ALTER TABLE i2 ENABLE KEYS; you will hear your floppy drive working for a while, during this time the processlist looks like this mysql> show processlist; +----+------+----------------+------+---------+------+-------------------+------ ----------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+----------------+------+---------+------+-------------------+----------------------------+ | 18 | root | localhost:4048 | test | Query | 28 | Repair by sorting | alter table i3 enable keys | | 21 | root | localhost:4051 | NULL | Query | 0 | NULL | showprocesslist | +----+------+----------------+------+---------+------+-------------------+----------------------------+ 2 rows in set (0.00 sec) after some time the floppy drive becomes silent and process list shows mysql> show processlist; +----+------+----------------+------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info| +----+------+----------------+------+---------+------+-------+------------------+ | 18 | root | localhost:4048 | test | Sleep | 4 | | NULL| | 21 | root | localhost:4051 | NULL | Query | 0 | NULL | show processlist| +----+------+----------------+------+---------+------+-------+------------------+ 2 rows in set (0.00 sec) so the server pretends it has finished the job but the client still waits on the result of the ALTER TABLE, it finally dies with ERROR 2013: Lost connection to MySQL server during query the i2.MYI file is still only 1K - try using the i2 table from another connection mysql> select * from i3; ERROR 1016: Can't open file: 'i3.MYI'. (errno: 144) - do a REPAIR on table i2 mysql> repair table i3; +---------+--------+----------+------------------------------------------------+ | Table | Op | Msg_type | Msg_text | +---------+--------+----------+------------------------------------------------+ | test.i3 | repair | warning | Number of rows changed from 645225 to 12921869 | | test.i3 | repair | status | OK | +---------+--------+----------+------------------------------------------------+ 2 rows in set (9.94 sec) (12921869 is the number of random integers in my i1 table)
[7 Oct 2004 10:03]
Hartmut Holzgraefe
in the step by step guide above some commands and results refere to a table i3, this was created identically to i2 and with the same symptoms so you can just replace i3 with i2
[7 Oct 2004 10:31]
Hartmut Holzgraefe
Using a floppy drive as tmpdir i get the same results on linux, too. The only difference here is that no physical access to the floppy drive ever happens. I assume this is due to the buffer cache.
[7 Oct 2004 16:02]
Ingo Strüwing
I took it back after hartmut found a way, how to reproduce it on Linux.
[7 Oct 2004 17:57]
Ingo Strüwing
Hartmut and I identified the following problems: - The returncode of activate_all_index() was not correctly handled. This suppressed the reply from server to client. - When the repair_by_sort() failed, no normal repair() was tried. The latter succeeds in this case. - After the (new) normal repair(), no trace of the "disk full" problem could be found. So we added a warning which shows up in the error log. bk commit - 4.0 tree (ingo:1.2029) BUG#5625
[14 Oct 2004 18:41]
Ingo Strüwing
Fixed in 4.0.22. Changeset: bk commit - 4.0 tree (ingo:1.2029) BUG#5625