Unique constraint error after 7.7 -> 7.9.4 upgrade

Having my first bumpy upgrade.
Centos 7.8
OpenJDK 11.0.8
PostGRES 9.6.19

Tried to upgrade from Sonar 7.7 to 7.9.4 and am getting this error when we try to run projects:

Error Details
org.apache.ibatis.exceptions.PersistenceException:

Error committing transaction. Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.db.measure.MeasureMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: Batch entry 1 insert into project_measures (

value,
metric_id,
component_uuid,
analysis_uuid,
text_value,
alert_status,
alert_text,
variation_value_1,
measure_data)
VALUES (
NULL,
105,
'AWZjho-Gaecqbn4F4Eo4',
'AXSy91SngmS5Ea8cDp0c',
NULL,
NULL,
NULL,
4.0,
NULL
) was aborted: ERROR: duplicate key value violates unique constraint "pk_project_measures"

Detail: Key (id)=(906287) already exists. Call getNextException to see other errors in the batch.

This is the first of a few of these errors that spits out all, complaining about the unique constraint for “pk_project_measures” and it’s occurring across all projects. I tried restoring the DB and reverting to SonarQube 7.7 but the same error happens (probably how I did the restore?)

We’re wondering if it’s safe to just update the sequence number to a larger value or if that’s going to mess up other things.

Thanks for any advice,
Rich

We think we’ve found where I broke this upgrade… this was self induced.

1 Like

Hi,

Welcome to the community and thanks for the follow-up!

 
Ann

I have the same the issue. Any help?

So what we had to do was drop all the databases and restore them to their pre-upgrade state to get working again. Just restoring in place wasn’t enough. It turns out I had forgotten the http://yourSonarQubeServerURL/setup and was trying to run the sonar scanner command line to test the new version (upgraded both at the same time) and started inserting records before the DB was in the upgraded state. Chaos ensued.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.