6
Incorrect key file for table 'widgets'; try to repair it 

This is the error message MySQL gives me when attempting to apply a new index to an existing (very large) table. Of course when I follow the error message's suggestion of trying to repair it:

mysql> repair table widgets;
+-------------------+--------+----------+---------------------------------------------------------+
| Table             | Op     | Msg_type | Msg_text                                                |
+-------------------+--------+----------+---------------------------------------------------------+
| tedsdb.widgets    | repair | note     | The storage engine for the table doesn't support repair | 
+-------------------+--------+----------+---------------------------------------------------------+
1 row in set (0.00 sec)

What's my best course of action here (following the obvious full backup before tinkering)?

UPDATE: I created a new table (MyISAM) of the same schema, copied over all the records (insert into select), the changed the engine on the new table (InnoDB), renamed the corrupt table and renamed the new table, then tried again and got the same error.

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Teflon Ted
  • 8,696
  • 19
  • 64
  • 78

3 Answers3

13

Looks like an old question, but I just ran into this problem. MySQL was writing out a temporary table to disk and the /tmp partition filled up.

Edwin Knuth
  • 156
  • 1
  • 3
0

I strongly suggest backing up before trying this.

Perform a dummy

ALTER TABLE widgets;
Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278
0

When we are doing Alter on innodb the "tmpdir" need to be observed. The Error 1034 : Key repair is definitely because of "tmpdir" full, and your alter will throw this error.

So I suggest when the Alter is got triggered give one more eye on your "tmpdir" utilization. If tmp is using 100% there you can see this error for sure :).

naveen_sfx
  • 727
  • 2
  • 9
  • 18