# Database upgrade fails when upgrading from 8.9 to 9.9

**URL:** <https://community.sonarsource.com/t/database-upgrade-fails-when-upgrading-from-8-9-to-9-9/84248>\
**Category:** SonarQube Server / Community Build\
**Created:** [February 17, 2023, 11:15am UTC](https://community.sonarsource.com/t/database-upgrade-fails-when-upgrading-from-8-9-to-9-9/84248 "2023-02-17T11:15:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grisu](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@Grisu](https://community.sonarsource.com/u/Grisu)\
**Post date:** [February 17, 2023, 11:15am UTC](https://community.sonarsource.com/t/database-upgrade-fails-when-upgrading-from-8-9-to-9-9/84248/1 "2023-02-17T11:15:26Z")

</div>

We have installed sonarqube 8.9.10 with postgresql . the database upgrade fails with the following message:

```auto
2023.02.17 10:18:41 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 #6700 'Move live measure variations to values' failed
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:79)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:67)
        at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:52)
        at org.sonar.server.platform.db.migration.engine.MigrationEngineImpl.execute(MigrationEngineImpl.java:66)
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doUpgradeDb(DatabaseMigrationImpl.java:105)
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doDatabaseMigration(DatabaseMigrationImpl.java:80)
        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:833)
Caused by: java.lang.IllegalStateException: Error during processing of row: [uuid=AX6b8sEHt6gyvapUNzCD,variation=0E-20]
        at org.sonar.server.platform.db.migration.step.SelectImpl.newExceptionWithRowDetails(SelectImpl.java:89)
        at org.sonar.server.platform.db.migration.step.SelectImpl.scroll(SelectImpl.java:81)
        at org.sonar.server.platform.db.migration.step.MassUpdate.execute(MassUpdate.java:93)
        at org.sonar.server.platform.db.migration.version.v98.VariationMigration.migrateVariation(VariationMigration.java:51)
        at org.sonar.server.platform.db.migration.version.v98.VariationMigration.execute(VariationMigration.java:41)
        at org.sonar.server.platform.db.migration.step.DataChange.execute(DataChange.java:44)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
        ... 9 common frames omitted
Caused by: java.sql.BatchUpdateException: Batch entry 34 update live_measures set value = 0.0 where uuid = 'AX60sMK8t6gyvapUV8Xp' was aborted: FEHLER: doppelter Schlüsselwert verletzt Unique-Constraint »live_measures_component«
  Detail: Schlüssel »(component_uuid, metric_uuid)=(AX60sMA_t6gyvapUV72-, 4)« existiert bereits. Call getNextException to see other errors in the batch.
        at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:165)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2367)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:560)
        at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:893)
        at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:916)
        at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1684)
        at com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:127)
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java)
        at org.sonar.server.platform.db.migration.step.UpsertImpl.addBatch(UpsertImpl.java:56)
        at org.sonar.server.platform.db.migration.step.MassUpdate.callSingleHandler(MassUpdate.java:120)
        at org.sonar.server.platform.db.migration.step.MassUpdate.lambda$execute$0(MassUpdate.java:93)
        at org.sonar.server.platform.db.migration.step.SelectImpl.scroll(SelectImpl.java:78)
        ... 14 common frames omitted
Caused by: org.postgresql.util.PSQLException: FEHLER: doppelter Schlüsselwert verletzt Unique-Constraint »live_measures_component«
  Detail: Schlüssel »(component_uuid, metric_uuid)=(AX60sMA_t6gyvapUV72-, 4)« existiert bereits.
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
        ... 24 common frames omitted

```

i have searched for the error in the sources and have found some parts, which could help for solving the problem.  
if i run the following query on the version 8.9.10, then i get many results:  
select component\_uuid, metric\_uuid, count(_)  
from live\_measures  
group by component\_uuid, metric\_uuid  
HAVING count(_) \> 1;

in different versions, the unique index “Live\_measures\_component” is created, which contains the columns component\_uuid and metric\_uuid. if i drop this index, then the upgrade runs. but is this the right way?

in the version 91 are some entries deleted in the table live\_measures, which are user defined. i have check in the database, if we have user defined entries with the query " SELECT lm.uuid FROM metrics m join live\_measures lm ON m.uuid = lm.metric\_uuid WHERE m.user\_managed \<\> ‘f’". Result is zero.

can someone solve the error?

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [February 17, 2023, 1:30pm UTC](https://community.sonarsource.com/t/database-upgrade-fails-when-upgrading-from-8-9-to-9-9/84248/4 "2023-02-17T13:30:24Z")

</div>

Hey there.

This looks like a duplicate thread.

> [@Error after upgrading from version 8.9 to 9.9](https://community.sonarsource.com/t/error-after-upgrading-from-version-8-9-to-9-9/83600):
>
> We Upgrade from Version 8.9.3 to the 9.9 lts version. with this upgrade we installed java 17 and postgresql 15, because both is needed in the newest version. we upgrade the database in postgresql from version 10 to version 15. Now, we have an error by running the analyse with the following message: Error Details org.sonar.ce.task.projectanalysis.component.VisitException: Visit of Component {key=\<hidden\>,type=PROJECT} failed at org.sonar.ce.task.projectanalysis.component.VisitException.rethro…

Please be patient – someone will looik at it soon.

I’ll close this thread.

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [February 17, 2023, 1:30pm UTC](https://community.sonarsource.com/t/database-upgrade-fails-when-upgrading-from-8-9-to-9-9/84248/5 "2023-02-17T13:30:27Z")

</div>


