Hello,
We are trying to upgrade our Sonar instance to 8.4, we made the hop from 6.7 to 7.9.3 LTS with no issue, but when we attempted the database upgrade for 8.4 we receive the below error:
2020.07.14 14:08:10 INFO web[][DbMigrations] #3311 'Remove column 'id' in 'components''...
2020.07.14 14:08:10 ERROR web[][DbMigrations] #3311 'Remove column 'id' in 'components'': failure | time=4ms
2020.07.14 14:08:10 ERROR web[][DbMigrations] Executed DB migrations: failure | time=405572ms
2020.07.14 14:08:10 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=405668ms
2020.07.14 14:08:10 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 #3311 'Remove column 'id' in 'components'' 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:405)
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:68)
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:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: Cannot find constraint for table 'components'
at org.sonar.server.platform.db.migration.version.v84.util.SqlHelper.contraintNotFoundException(SqlHelper.java:113)
at org.sonar.server.platform.db.migration.version.v84.util.SqlHelper.getPostgresSqlConstraint(SqlHelper.java:66)
at org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator.generate(DropPrimaryKeySqlGenerator.java:52)
at org.sonar.server.platform.db.migration.version.v83.DropIdFromComponentsTable.execute(DropIdFromComponentsTable.java:42)
at org.sonar.server.platform.db.migration.step.DdlChange.execute(DdlChange.java:45)
at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
... 9 common frames omitted
It looks as though the migration itself creates this table by renaming Projects:
2020.07.14 14:01:29 INFO web[][DbMigrations] #3204 'Rename table 'PROJECTS' to 'COMPONENTS''...
2020.07.14 14:01:29 INFO web[][DbMigrations] #3204 'Rename table 'PROJECTS' to 'COMPONENTS'': success | time=6ms
2020.07.14 14:01:30 INFO web[][DbMigrations] #3207 'Drop 'TAGS' column from COMPONENTS table'...
2020.07.14 14:01:30 INFO web[][DbMigrations] #3207 'Drop 'TAGS' column from COMPONENTS table': success | time=7ms
sonar-ets/c916737a-2754-434b-b0ac-36c288debdbd:/var/vcap/packages/sonar/sonar/logs$ 2020.07.14 14:05:30 INFO web[][o.s.s.p.d.m.s.MassUpdate] 359 rows processed (1 items/sec)
We noticed that there is mixed case sensitivity, but cannot confirm if this is the cause. We also recently migrated from Mysql to Postgresql before performing our 6.7 to 7.9 upgrade. Additionally we reproduced this on Postgresql 9.6 and 10.6 and we had no issue running the “Drop Column” command manually against the databases in question.
Steps to reproduce:
- Setup 6.7 empty instance.
- Upgrade to 7.9.3 LTS
- Attempt Database Upgrade to 8.4.0
Thanks,
Brandon