Bug #12946 Duplicate key for record
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>
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.