We are upgrading sonarqube Enterprise from 10.3 to 10.8
During the migration, the process froze for hours at:
web[][DbMigrations] 4/65 #104003 'Populate 'rule_tags' table'...
After waiting, I restarted the sonarqube service, which allowed the migration to continue.
However, the migration again halted again for more than 15 hours, leaving me no choice but to restart the service:
Error:
2025.02.28 22:02:44 INFO web[][DbMigrations] 42/62 #108006 'Migrate the content of 'live_measures' to 'measures' for portfolios'...
2025.02.28 22:02:44 INFO web[][o.s.s.p.d.m.v.v.AbstractMigrateLiveMeasuresToMeasures] Starting the migration of 21 portfolios (total number of portfolios: 21)
2025.02.28 22:17:44 INFO web[][o.s.s.p.d.m.s.MassUpdate] 0 rows processed (0 items/sec)
2025.02.28 22:18:44 INFO web[][o.s.s.p.d.m.s.MassUpdate] 0 rows processed (0 items/sec)
2025.02.28 22:19:44 INFO web[][o.s.s.p.d.m.s.MassUpdate] 0 rows processed (0 items/sec)
2025.02.28 22:20:44 INFO web[][o.s.s.p.d.m.s.MassUpdate] 0 rows processed (0 items/sec)
2025.02.28 22:21:26 INFO web[][o.s.s.p.d.m.s.MassUpdate] 21 rows processed (0 items/sec)
2025.02.28 22:21:26 INFO web[][o.s.s.p.d.m.s.MassUpdate] 11428 rows processed (190 items/sec)
However, this time, restarting the service created duplicate records in the measures
table, leading to a failure when attempting to add the Primary Key.
2025.03.01 12:17:34 INFO web[][DbMigrations] 1/21 #108006 'Migrate the content of 'live_measures' to 'measures' for portfolios': success | time=3743ms
2025.03.01 12:17:34 INFO web[][DbMigrations] 2/21 #108007 'Create primary key on 'measures' table'...
2025.03.01 12:17:35 ERROR web[][DbMigrations] 2/21 #108007 'Create primary key on 'measures' table': failure | time=1408ms
2025.03.01 12:17:35 ERROR web[][DbMigrations] Executed 1/21 DB migrations: failure | time=5155ms
2025.03.01 12:17:35 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=5216ms
org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #108007 'Create primary key on 'measures' table' 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)
Caused by: java.lang.IllegalStateException: Fail to execute ALTER TABLE measures ADD CONSTRAINT pk_measures PRIMARY KEY (component_uuid)
at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(DdlChange.java:106)
at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(DdlChange.java:86)
Caused by: org.postgresql.util.PSQLException: ERROR: could not create unique index "pk_measures"
Detail: Key (component_uuid)=(AZUY7nPnbvgAjB18WEXT) is duplicated.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2733)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2420)