Dbase migration fails 10.8.0.100206

The two records are the same; however, when looking at the created_at/updated_at fields, there is one from January 20 (which makes sense) and one from December 6.

This is probably the date you made the first attempt to upgrade, and I suspect the way you are restoring the backup is not removing the newly created measures table.
Can you try again, but make sure to truncate or drop the measures table before starting the upgrade?

It worked. Thank you very much.

Any input as to what in my backup/restore commands that could have caused this?

Backup:
pg_dump -U sonar -W -F t sonar > *filename*.tar

Restore:
pg_restore -U sonar --clean -d sonar *filename*.tar 
1 Like

Great! Thanks for the update.

I’m not an expert on that, but I believe you would have to drop the entire db before restoring. The --clean option will only drop and re-create the tables (or other objects) that are part of the dump. So in this case it didn’t touch the measures table which doesn’t exist in the dump.

2 Likes

Hello @HaNs_Neefs, @haugsrud and @AngelaMarie,
We are trying to identify why the migration is failing with an out of memory error. Are you using the community plugin dependency-check or any other custom plugin? Thanks.

Yes. I am using these.

1 Like

no plugins

Sorry previous was wrong we have the dependency-check plugin installed.

This is the only plugin.

2 Likes

I am getting this same DB Migration failure

Current SonarQube Version: 9.9.8

Target SonarQube Version:24.12.0.1006

I have set the sonar.properties with:

sonar.web.javaOpts=-Xmx4G
sonar.ce.javaOpts=-Xmx4G

2025.09.25 11:43:32 ERROR web[o.s.s.p.d.m.DatabaseMigrationImpl] DB migration ended with an exception
org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #108003 ‘Migrate the content of ‘live_measures’ to ‘measures’ for branches’ failed
at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:112)
at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:97)
at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:70)
at org.sonar.server.platform.db.migration.engine.MigrationEngineImpl.execute(MigrationEngineImpl.java:55)
at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doUpgradeDb(DatabaseMigrationImpl.java:106)
at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doDatabaseMigration(DatabaseMigrationImpl.java:81)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (SONARQUBE.PK_MEASURES) violated

After the failure, I run the following script:

SELECT SUM(count) as total_duplicates
FROM (
SELECT component_uuid, COUNT() as count
FROM measures
GROUP BY component_uuid
HAVING COUNT(
) > 1
) duplicates

And get these results:

Total Duplicates:

1 (null)

So, it looks like it is trying to put two null values in my table.

Any thoughts on what I can check or do? And is there anyway to fix and restart or do I need to reload the backup of the DB Schema?

Thanks

M@

Hello @mattgoodnight,
I suppose the migration failed a first time and was relaunched a second time, leading to this issue.
The easiest solution is to restore your backup and relaunch.

I’ve restored and retried 3 times. Really looking for a better solution, as that doesn’t work. Is there anyway to fix the DB and then continue with the migration?

Thanks

Are you sure the measures table is dropped when you restore the backup? Depending on your restoration method, the table may not be removed since it’s a new one.
Please make sure the table doesn’t exist or is empty before restarting the upgrade.