Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ON DUPLICATE not working

Status
Not open for further replies.

azzazzello

Technical User
Jan 25, 2005
297
US
greetings,

Something rather strange is happening here...Since server reboot, all the sudden, the following sniplet of code...


Code:
insert into MY_TABLE (MID,PARTNER) values('123','PTR2') ON DUPLICATE KEY UPDATE PARTNER = VALUES(PARTNER);

is generating the following error

Code:
ERROR 1062 (23000): Duplicate entry '123' for key 1

MID is the primary key for the table. There are other keys, but only MID is primary. There IS a '123' MID in the table, but it's supposed to be updated by DUPLICATE KEY line. I have created a table identical to MY_TABLE and tan the same line )twice of course) to see if the problem is manifested there too. It was not - the update took place just fine.

Since the last server reboot, however, the MY_TABLE table cannot be updated using INSERT...ON DUPLICATE KEY UPDATE syntax. It CAN be updated using UPDATE syntax

The table is MyISAM, server version 4.1.15-standard-log. Server is Red Hat Enterprise Linux ES release 4 (Nahant Update 1).

Help? :)
 
OK. Solved the problem. MySQL server was killed for memory-starvation reasons by kernel during updates. This corrupted the table, somehow putting several rows in a weird limbo, where they could not be updated. myisamchk -r fixed the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top