Mysql – How to repair a TokuDB table

corruptionMySQLtokudb

I have a TokuDB table that works fine for most queries, but segfaults on others. I did a CHECK TABLE which indicated that the table had errors.
However, TokuDB doesn't support REPAIR TABLE. How can I fix a corrupted TokuDB table?

mysql> check table XXX;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    1
Current database: XXX



+------------------------------------------------+-------+----------+----------+
| Table                                          | Op    | Msg_type |     Msg_text |
+------------------------------------------------+-------+----------+----------+
| XXX.XXX | check | error    | Corrupt  |
+------------------------------------------------+-------+----------+----------+
1 row in set (14 hours 17 min 55.05 sec)

mysql> repair table XXX;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    2
Current database: XXX

+------------------------------------------------+--------+----------+---------------------------------------------------------+
| Table                                          | Op     | Msg_type |     Msg_text                                                |
+------------------------------------------------+--------+----------+---------------------------------------------------------+
| XXX.XXX | repair | note     | The storage engine for the table doesn't support repair |
+------------------------------------------------+--------+----------+---------------------------------------------------------+
1 row in set (0.84 sec)

Best Answer

TokuDB does not support the repair table command, just like InnoDB, so you can't repair the table in question. If you don't have a backup or slave to pull from the best you can do is select the rows from the readable portion of the table itself. I'd recommend using "select * from table_name where table_pk < ? into ;" and "select * from table_name where table_pk > ? into ;". You'll need to experiment with the ? for each statement, because once you read the damaged part of the file the server will crash.