Problem during db migration from LTS 6.7.4 to LTS 7.9

Hello,

During Database migration, I get the following stacktrace. I’m trying to upgrade from 6.7.4 to 7.9. Could it be due to the fact I haven’t upgraded to latest 6.7 LTS ?
Thank you
Dom

2019.07.02 16:49:12 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 #1945 'Delete file measures' 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: Error during processing of row: [uuid=b031b1cd-3eb7-45e7-bda6-139ecc4c105d]
	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:92)
	at org.sonar.server.platform.db.migration.version.v70.DeleteFileMeasures.execute(DeleteFileMeasures.java:41)
	at org.sonar.server.platform.db.migration.step.DataChange.execute(DataChange.java:45)
	at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
	... 9 common frames omitted
Caused by: java.sql.BatchUpdateException: Incorrect syntax near 'pm'.
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:2083)
	at org.apache.commons.dbcp2.DelegatingStatement.executeBatch(DelegatingStatement.java:223)
	at org.apache.commons.dbcp2.DelegatingStatement.executeBatch(DelegatingStatement.java:223)
	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:119)
	at org.sonar.server.platform.db.migration.step.MassUpdate.lambda$execute$0(MassUpdate.java:92)
	at org.sonar.server.platform.db.migration.step.SelectImpl.scroll(SelectImpl.java:78)
	... 13 common frames omitted
3 Likes

Dom,

Can you give some more details like database platform (Postgres, MSSQL, Oracle) and version (MSSQL 2014, for example)?

Colin

1 Like

Hello,

It’s MSSQL SQL Server v2014.

I guess there is a problem with the statement used in DeleteFileMeasures :

delete from project_measures pm where pm.component_uuid=?

It can’t work on my instance of SQL Server because of the alias ‘pm’ used in statement.

delete from project_measures where component_uuid=?

would work.

I don’t know if it’s specific to my environment.
Dom

Judging from this entry, you must use the ‘AS’ keywork in a DELETE statement. Don’t know why.
So the correct statement should be

delete from project_measures AS pm where pm.component_uuid=?

Dom,

Thanks for the investigation!

A ticket has been created which will make its way into a 7.9.1 release SONAR-12260

This, combined with SONAR-12251, might be good enough reason to wait for a 7.9.1 release to make the upgrade.

Colin

1 Like

Hi ,
I am facing the same issue, migrating from 6.7.3 to 7.9.
Is there any workaround that I can use to fix this up ?

Please suggest if there is a way to currently fix this in 7.9.

Until a fix is released I’d recommend reverting to a backup of your 6.7 instance.

Currently we migrated to open Jdk11 , after that coverage is shown as 0 in sonar 6.7.3.
That’s why we needed to migrated urgently to 7.9.

Please suggest if I can proceed with 6.7.3 without coverage issue.

Neeta,

It sounds like you may have jumped to a conclusion that v7.9 LTS will fix your coverage reporting issue, and I don’t think there’s any guarantee of that. I would recommend opening a new thread with those details in the context of your v6.7 install.

Colin

1 Like

Hi Colin,
actually I set up 7.9 from scratch and my coverage worked fine.
Now the issue is I need to upgrade my existing sonar db so that I do not lose any data.
Thanks in advance for quick turnaround.