Bug #3822 error 1034: Incorrect key file for table
Submitted: 18 May 2004 22:48 Modified: 23 Sep 2004 15:55
Reporter: Matthew Costello Email Updates:
Status: No Feedback Impact on me:
Category:MySQL Server: MyISAM storage engine Severity:S1 (Critical)
Version:4.1.1-alpha OS:Linux (Linux 2.4.20 (RH9))
Assigned to: CPU Architecture:Any

[18 May 2004 22:48] Matthew Costello
UPDATE to a new MyISAM table results in

ERROR 1034 at line 5404: Incorrect key file for table: 'Track'; try to repair it

MySQL is running on a updated Red Hat 9 using the source distribution compiled using a spec file.
  mysql  Ver 14.3 Distrib 4.1.1-alpha, for pc-linux (i686)

The sequence of commands is:
    CREATE TABLE Track ...
    UPDATE TABLE Track SET ... [many times]

p.s. I am aware of bug # 1166, which may or may not be related.
     No error occurs when using an InnoDB table.

How to repeat:
Retrieve the 220k tar image from

Untar the file to create the directory bug-1034a/.
The tar file contains a README file, a script and data
files to reproduce the bug, and a copy of the spec file.
Edit the 'bug.sh' script to set the mysql username.

mysql="mysql -u root"
set -ex
$mysql -e "DROP DATABASE IF EXISTS $dbname"
$mysql -e "CREATE DATABASE $dbname CHARACTER SET utf8"
$mysql < create1.sql $dbname
$mysql -e "LOAD DATA INFILE '$tbl' INTO TABLE Track" $dbname
$mysql < create2.sql $dbname
$mysql < ta.sql $dbname

Run the bug.sh script.
[20 May 2004 12:34] Alexander Keremidarski
Can't repeat the corruption with current 4.1 from BK tree 
ChangeSet@1.1849.9.2, 2004-05-20 14:21:30+05:00, ram@gw.mysql.r18.ru

Most probably this problem is is gone with the fix of http://bugs.mysql.com/bug.php?id=1166
[20 May 2004 20:14] Matthew Costello
The fix for #1166 should be in 4.1.1alpha because the currently released version of 4.1.1alpha was released in December, 3 months after 1166 was pronounced fixed. I'd try this on 4.0.20 except that I need UTF-8 support.

How about a new version of 4.1.1alpha?
[31 May 2004 20:46] Matthew Costello
Verified fixed in 4.1.2-alpha.
[23 Aug 2004 10:00] Andreas Götz
I've experienced the same issue running 4.1.3 on WinXP SP1, issue could be fixed using myisamchk -r (as -e crashaes as reported in separate bug). Corrupted files can be made available on request, let me know.

[23 Aug 2004 15:55] MySQL Verification Team
We are very eager to fix all our bugs, especially crushing ones and ones leading to corruption. 

But to help us do that we need input from you.

E.1.6 Making a Test Case If You Experience Table Corruption

If you get corrupted tables or if mysqld always fails after some
update commands, you can test if this bug is reproducible by doing the

    * Take down the MySQL daemon (with mysqladmin shutdown).

    * Make a backup of the tables (to guard against the very unlikely
    * case that the repair will do something bad).

    * Check all tables with myisamchk -s database/*.MYI. Repair any
    * wrong tables with myisamchk -r database/table.MYI. It is even
    * better to use mysqlcheck as it does not require shutting down
    * MySQL server 

    * Make a second backup of the tables.

    * Remove (or move away) any old log files from the MySQL data
    * directory if you need more space.

    * Start mysqld with --log-bin. See section 4.9.4 The Binary
    * Log. If you want to find a query that crashes mysqld, you should
    * use --log --log-bin.

    * When you have gotten a crashed table, stop the mysqld server.
    * Restore the backup.
    * Restart the mysqld server without --log-bin

    * Re-execute the commands with mysqlbinlog update-log-file |
    * mysql. The update log is saved in the MySQL database directory
    * with the name hostname-bin.#.

    * If the tables are corrupted again or you can get mysqld to die
    * with the above command, you have found reproducible bug that
    * should be easy to fix! FTP the tables and the binary log to
    * ftp://support.mysql.com/pub/mysql/Incoming/ and enter it into our
    * bugs system at http://bugs.mysql.com/. If you are a support
    * customer), you can also support@mysql.com to alert the MySQL
    * team about the problem and have it fixed as soon as possible.

You can also use the script mysql_find_rows to just execute some of
the update statements if you want to narrow down the problem.
[19 Sep 2004 23:23] Vaclav Vobornik
I have the very similar problem:

Today's BK version - Mysql-4.1.5-gamma, Linux 2.4.26

MyISAM table with utf8 fields, many indexes and fulltext:

CREATE TABLE items_utf8 (
  iid bigint(20) NOT NULL auto_increment,
  channel_id int(10) unsigned NOT NULL default '0',
  title varchar(255) collate utf8_unicode_ci NOT NULL default '',
  link varchar(255) collate utf8_unicode_ci NOT NULL default '',
  description text collate utf8_unicode_ci NOT NULL,
  pubdate datetime NOT NULL default '0000-00-00 00:00:00',
  active datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (iid),
  UNIQUE KEY link (link),
  KEY pubdate (pubdate),
  KEY channel_id (channel_id),
  KEY active (active),
  FULLTEXT KEY `full` (title,description)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='jednotlive zpravy';

No of rows:450 805
Data (.MYD):130 MB
Index (.MYI): 124MB

And when I use this command:

UPDATE LOW_PRIORITY items_utf8 SET channel_id = '542',
title = 'Nove diskusni forum o mobiloch Motorola',
description = 'Administrator napisal novy clanok',
active = now( ) WHERE link = _binary'http://www.madaj.net/t720/' LIMIT 1 

MySQL generate error:  

#1034 - Incorrect key file for table 'items_utf8'; try to repair it 

mysql> repair table items_utf8 use_frm;
| Table      | Op     | Msg_type | Msg_text                                        |
| items_utf8 | repair | info     | Delete link points outside datafile at 12267504 |
| items_utf8 | repair | warning  | Number of rows changed from 0 to 450803         |
| items_utf8 | repair | status   | OK                                              |

New "update" command corrupts this table again :-(

The same table in charset cp1250 works fine - does not produce any errors
[20 Sep 2004 7:18] Vaclav Vobornik
I have send table files (frm, MYD, MYI) to ftp://support.mysql.com/pub/mysql/Incoming/corrupted-myisam-20040920.tar.bz2 
Use "update items_utf8" command above for reproducing the error.
[14 Feb 2005 22:54] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".