Description:
When we do large deletes on tables with analyse table, we get
this error for this tables --> 'duplicate key for record'
-------------------------------------------------------+
| Table | Op | Msg_type | Msg_text
|
+-------------------------------------+--------+----------+------------
-------------------------------------------------------+
| db1.table_1 | repair | warning | Duplicate
| key for record at 252512316 against record at 113290002 |
db1.table_1 | repair | warning | Duplicate key for
record at 252513072 against record at 133629090 |
| db1.table_1 | repair | warning | Number of rows
changed from 16004043 to 16004014 |
| db1.table_1 | repair | status | OK
mysql> show create table db1.table_1;
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| table_1 | CREATE TABLE `table_1` (
`Number` int(10) unsigned NOT NULL default '0',
`hint` char(32) NOT NULL default '',
`id` int(10) unsigned NOT NULL default '0',
`day` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`Number`,`day`)
) TYPE=MyISAM |
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
How to repeat:
Do large deletes with analyse table for a MyISAM table, than you get this error.
Suggested fix:
When we have this error, we have to run repair two times to get it up and running again.
mysql> repair table db1.table_1;
-------------------------------------------------------+
| Table | Op | Msg_type | Msg_text
|
+-------------------------------------+--------+----------+------------
-------------------------------------------------------+
| db1.table_1 | repair | warning | Duplicate
| key for record at 252512316 against record at 113290002 |
db1.table_1 | repair | warning | Duplicate key for
record at 252513072 against record at 133629090 |
| db1.table_1 | repair | warning | Number of rows
changed from 16004043 to 16004014 |
| db1.table_1 | repair | status | OK
mysql> repair table db1.table_1;
+-------------------------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+-------------------------------------+--------+----------+----------+
| db1.table_1 | repair | status | OK |
+-------------------------------------+--------+----------+----------+
1 row in set (1 min 58.10 sec)
mysql>