Duplicate key value alert on an insert statement prevents the Upgrade Wizard from starting

In the Admin dashboard, SuiteCRM says we are running 7.11.2 and we would like to upgrade. When we click Administrator > Admin > Upgrade Wizard, it says database failure. The suitecrm.log file says “Error inserting into table: upgrade_history: Query Failed: INSERT INTO upgrade_history” and MySQL error 1062: Duplicate entry ‘375c682a51ada71ed57432c16918b274’ for key ‘upgrade_history_md5_uk’".

It says the error handling is on line 400 of “/var/www/html/SuiteCRM/include/MVC/Controller/SugarController.php” and that line pertains to the logging. Should remove that line or is there something I can do in the database to remove the duplicate key value error? Has anybody else experienced this issue before?

Thanks in advance,

Curtis

1 Like

Hi Curtis, welcome. The first posts of each user need to be manually approved, it’s an anti-spam measure. This is why you had trouble posting, it should be ok from now on.

About your issue: I never saw this error before.

Can you check what’s on your database, in table upgrade_history? You can try using phpMyAdmin to see it, for example.

It sounds like your upgrade table already knows about this file you’re uploading, but I would like to check it is recorded as “installed” or something else. it really shouldn’t give this ugly error: at most, it would inform you that the upgrade is already installed.

It might help to clear out the upload/upgrades directory, which can have some broken left-over from previous upgrade attempts.

So this won’t let me upload a file for some reason, but I’ll list some snippets (this will probably look pretty ugly) from the SQL select statement from upgrade_history and the logs from the server after attempting an upgrade. I can see the entry for that duplicate key it is listed as installed for the current version we are running. Thank you for taking a look.

Log snippet from the server

Mon Jun  3 13:39:49 2019 [15071][1][INFO] Query:INSERT INTO upgrade_history (id,filename,md5sum,type,status,version,manifest,date_entered,enabled)
					VALUES ('5bbcc3a9-e7c4-c283-5f90-5cf55b9f6c8f','upload://upgrades/patch/SuiteCRM-Upgrade-7.11.x-to-7.11.2.zip','375c682a51ada71ed57432c16918b274','patch','installed','7.11.2','','2019-06-03 17:39:47',1)
Mon Jun  3 13:39:49 2019 [15071][1][FATAL] Mysqli_query failed.
Mon Jun  3 13:39:49 2019 [15071][1][INFO] Query Execution Time:0.0040669441223145
Mon Jun  3 13:39:49 2019 [15071][1][FATAL] Error inserting into table: upgrade_history: Query Failed: INSERT INTO upgrade_history (id,filename,md5sum,type,status,version,manifest,date_entered,enabled)
					VALUES ('5bbcc3a9-e7c4-c283-5f90-5cf55b9f6c8f','upload://upgrades/patch/SuiteCRM-Upgrade-7.11.x-to-7.11.2.zip','375c682a51ada71ed57432c16918b274','patch','installed','7.11.2','','2019-06-03 17:39:47',1): MySQL error 1062: Duplicate entry '375c682a51ada71ed57432c16918b274' for key 'upgrade_history_md5_uk'
Mon Jun  3 13:39:49 2019 [15071][1][DEBUG] Hook called: ::server_round_trip
Mon Jun  3 13:39:49 2019 [15071][1][DEBUG] Calling MySQLi::disconnect()
Mon Jun  3 13:39:49 2019 [15071][1][FATAL] Exception handling in /var/www/html/SuiteCRM/include/MVC/Controller/SugarController.php:400
Mon Jun  3 13:39:49 2019 [15071][1][FATAL] Exception in Controller: Database failure. Please refer to suitecrm.log for details.
Mon Jun  3 13:39:49 2019 [15071][1][FATAL] backtrace:

Trimmed down results of “SELECT * FROM upgrade_history;” for the DB

There are many entries, but this is the one it is complaining about

 id                                   | filename                                                      | md5sum                           | type  | status    | version | name | description | id_name | manifest                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | date_entered        | enabled |
+--------------------------------------+---------------------------------------------------------------+----------------------------------+-------+-----------+---------+------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------+
| b4a9ae10-6446-833e-7ea4-5c881f040ddd | upload://upgrades/patch/SuiteCRM-Upgrade-7.11.x-to-7.11.2.zip | 375c682a51ada71ed57432c16918b274 | patch | installed | 7.11.1  | NULL | NUL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sbGFibGUiO2I6MDtzOjI1OiJvZmZsaW5lX2NsaWVudF9hcHBsaWNhYmxlIjtiOjE7czo0OiJuYW1lIjtzOjg6IlN1aXRlQ1JNIjtzOjE0OiJwdWJsaXNoZWRfZGF0ZSI7czoxOToiMjAxOS0wMi0yMC0xNzowMDowMCI7czo0OiJ0eXBlIjtzOjU6InBhdGNoIjtzOjc6InZlcnNpb24iO3M6NjoiNy4xMS4yIjt9czoxMToiaW5zdGFsbGRlZnMiO3M6MDoiIjtzOjE2OiJ1cGdyYWRlX21hbmlmZXN0IjtzOjA6IiI7fQ== | 2019-03-12 21:04:16 |       1 |

And when you go in the menu on the top-right and select “about”, which version does it say you have installed now?

Supposedly you should have at least that 7.11.1 which says is “installed”

Correct, the About page says 7.11.2 is the current version. I haven’t tried deleting the contents of the upload/upgrades directory like you suggested earlier.

But which package are you trying to use for the upgrade now? Is it also a SuiteCRM-Upgrade-7.11.x-to-7.11.2.zip ?

Can you try downloading a new package? A new release came out yesterday.

If necessary I suggest you edit the ID in that row in the database (‘5bbcc3a9-e7c4-c283-5f90-5cf55b9f6c8f’), just change a number somewhere.

So I don’t actually get the opportunity to upload the new zip file. As soon as I click the Upgrade Wizard utility form the Admin page, I receive the following error message “Database failure. Please refer to suitecrm.log for details.” It never gets to the system check or the upload page. Then when I read the suitecrm.log, that’s where I see the duplicate key error. I can try to change that key value in the database and attempt an upgrade.

I have a positive feeling that you will be able to overcome this hurdle in one of the two suggested ways

  • change the id in the database

  • clear the upload/upgrades directory

Thank you for your help! Clearing the upload/upgrades directory solved our issue. It is now prompting me to upload the new zip file. I can’t continue the upgrade until I schedule downtime and get it approved, but I’m fairly certain it will be successful. Thanks again for the help.

Curtis