Database upgrade failed

Hello,
I am in the process of upgrading from 7.4.2 up to eventually 9.2.4. My first upgrade was from 7.4 to 7.9.6 LTS, and on the next leg, going to 8.9.6 I received an Upgrade Failed message. and this in the logs:

2022.01.20 17:48:22 INFO  web[][DbMigrations] #3438 'Drop column 'ID' of 'PROJECT_MEASURES' table'...
2022.01.20 17:48:22 ERROR web[][DbMigrations] #3438 'Drop column 'ID' of 'PROJECT_MEASURES' table': failure | time=36ms
2022.01.20 17:48:22 ERROR web[][DbMigrations] Executed DB migrations: failure | time=37ms
2022.01.20 17:48:22 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=131ms
2022.01.20 17:48:22 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 #3438 'Drop column 'ID' of 'PROJECT_MEASURES' table' 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:830)
Caused by: java.lang.IllegalStateException: Fail to execute ALTER TABLE project_measures DROP COLUMN id
	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)
	at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(DdlChange.java:128)
	at org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn.execute(DropIdColumn.java:39)
	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
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The index 'measures_sid_metric' is dependent on column 'id'.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1632)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:872)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:767)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7418)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3274)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:247)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:222)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:743)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
	at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(DdlChange.java:91)
	... 14 common frames omitted

How can I go about fixing this and continuing on with the upgrade?

Hey there.

This index should have been dropped a long time ago (in SonarQube *v6.0)! I would suggest you drop the index manually and see if the rest of the migration succeeds (you have made it through quite a few column drops already if you made it to step #3438, maybe this is a one-off)

DROP INDEX measures_sid_metric ON project_measures;

1 Like

Thank you Colin - I had found this post Upgrade from 7.9.6 LTS to 8.9.0 LTS failed - Get help / SonarQube - SonarSource Community
which pretty much said the same thing. I deleted that index and one other on the same table and was able to complete the upgrade without issue to 9.4.2

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