We have a C# app that has been working on three machines, 2 running Mono and 1 running Windows succesfully for the last 4 years.
Recently, we had a crash and updated the Windows machine while doing the repair. MySql on the machine is 5.5.16
Post the update, the app is now throwing the error in the title “Unhandled Exception: MySql.Data.MySqlClient.MySqlException: Duplicate entry ‘CC2-2012-04-10-201205’ for key ‘PRIMARY'”
- None of the fields are auto-incremented
- We are using a DbDataAdapter
- The sql statement is an UPDATE
- All the indexes, table strucutures, privileges etc appear to be the same across all servers
- There are no triggers on the tables
- We have dropped and repaired the tables and indexes over and over to no avail
- We have tried MyIASM and InnoDB (We initially used InnoDB)
I have no idea how an update statement can fail with a duplicate key, about the nearest solution I have found was a MySql error many, many versions ago here:
http://bugs.mysql.com/bug.php?id=27650
But that was repaired many years ago apparently.
Anyone have any ideas where I can look next?
The issue turned out to be a version mismatch between the ADO.NET Driver for MySQL (Connector/NET) and the MySQL server version. Pretty obvious really.
The ADO driver we were using turned out to be a fairly old version, and there must have been some major changes in the meanwhile.
Simply upgrading the mysql.data.dll fixed everything up
EDIT: Confirmed, we were using a very old MySql.Data ADO.NET driver version 1.0.10.1
This worked with MySql server 5.1.53 and below. (This was the highest server version we had where our code still worked)
Once we upgraded to MySql server version 5.5.24 the apps all began failing with the DataAdapter excepting out with duplicate records (where there were none)