Upgrading sonarqube community edition from version 6.7.7 to 7.9.3 Drop unique index on QUALITY_GATES.NAME': failure

Environment
Windows Server 2019
MS SQL server 2017
Java version 11.0.7

we are trying to upgrade from Sonarqube version 6.7.7 with Java 11 and MS SQL server 2017 to Sonarqube version 7.9.3 with Java 11 and MS SQL 2017.

Error we are seeing in the web.log is

2020.07.13 10:43:54 INFO  web[][o.s.s.p.w.MasterServletFilter] Initializing servlet filter org.sonar.server.ws.WebServiceFilter@5f65c1f2 [pattern=UrlPattern{inclusions=[/api/system/migrate_db.*, ...], exclusions=[/api/properties*, ...]}]
2020.07.13 10:43:54 INFO  web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2020.07.13 10:44:20 INFO  web[][o.s.s.p.d.m.DatabaseMigrationImpl] Starting DB Migration and container restart
2020.07.13 10:44:20 INFO  web[][DbMigrations] Executing DB migrations...
2020.07.13 10:44:20 INFO  web[][DbMigrations] #1951 'Drop unique index on QUALITY_GATES.NAME'...
2020.07.13 10:44:20 ERROR web[][DbMigrations] #1951 'Drop unique index on QUALITY_GATES.NAME': failure | time=21ms
2020.07.13 10:44:20 ERROR web[][DbMigrations] Executed DB migrations: failure | time=24ms
2020.07.13 10:44:20 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=172ms
2020.07.13 10:44:20 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 #1951 'Drop unique index on QUALITY_GATES.NAME' 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 java.base/java.lang.Iterable.forEach(Iterable.java:75)
	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: Fail to execute DROP INDEX uniq_quality_gates ON quality_gates
	at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:97)
	at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:77)
	at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:117)
	at org.sonar.server.platform.db.migration.version.v70.DropUniqueIndexOnQualityGatesName.execute(DropUniqueIndexOnQualityGatesName.java:35)
	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: Cannot drop the index 'quality_gates.uniq_quality_gates', because it does not exist or you do not have permission.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1621)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:868)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:768)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2935)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:248)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:223)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:744)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:175)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:175)
	at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:82)
	... 14 common frames omitted

I have verified that “quality_gates.uniq_quality_gates”, does exists in the database and user have permission to that index.
There is plenty of free space on the server

Any help?

Thanks

Welcome to the community! It looks like you have sorted things out here, as you created another post saying that the migration was successful. Could you please tell us how did you resolved your issue? That would be helpful for next visitors in this page.

As you can see above, most of my issues were related to indexes.
For example “quality_gates.uniq_quality_gates”, In this example, this is complaining about table name “quality_gates” and index name “uniq_quality_gates”. It’s joining the table name and index name with a “.”.
Where as my database had the same key defined as “quality_gates$uniq_quality_gates”. So when database migration was happening, it would complain key not found or permissions not correct.
So i had to go inside my database and correct the key’s.
I would rename my existing key “quality_gates$uniq_quality_gates” to “uniq_quality_gates”. This way when database upgrade would run, it would look for “quality_gates.uniq_quality_gates”. Where “quality
-gates” would be the table name and join that with my newly renamed key “uniq_quality_gates”.
Painful process for me but i had to do it. Once i took care off the key’s / Indexes, DB migration went fine.

1 Like