Failed Upgrade to 8.9LTS on DB issue

We tried to upgrade today version 7.9.2 (build 30863) to version 8.9.2 (build 46101) in our prod environment and we had to roll back. :frowning:

The reason is the error below during the DB upgrade.
Does anyone know how ti can be fixed?
Thanks

The error:

2021.11.04 18:14:32 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=78ms
2021.11.04 18:14:32 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 #3105 'Migrate Azure ALM settings from PROPERTIES to ALM_SETTINGS tables' 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:829)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
                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.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:602)
                at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:524)
                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.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:505)
                at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:94)
                at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:94)
                at org.sonar.server.platform.db.migration.step.UpsertImpl.execute(UpsertImpl.java:66)
                at org.sonar.server.platform.db.migration.version.v81.MigrateAzureAlmSettings.insertAlmSetting(MigrateAzureAlmSettings.java:144)
                at org.sonar.server.platform.db.migration.version.v81.MigrateAzureAlmSettings.loadOrInsertAlmSettings(MigrateAzureAlmSettings.java:114)
                at org.sonar.server.platform.db.migration.version.v81.MigrateAzureAlmSettings.execute(MigrateAzureAlmSettings.java:67)
                at org.sonar.server.platform.db.migration.step.DataChange.execute(DataChange.java:44)
                at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
                ... 9 common frames omitted

Any idea what causes the issue and how we can resolve it ?

Hello @jfrizand . This database update is designed to migrate Azure settings (and secrets) from the properties table to a new alm_settings table. It looks like one of your secrets/tokens is not fitting the new table, which is unexpected.

Could you please tell us whatā€™s the length of the token in the property table? (Please make sure you use the len() function and donā€™t leak any secrets on this public space :smiley: )

select len(text_value) from properties where prop_key = 'sonar.pullrequest.vsts.token.secured'

The target column in the alm_settings is 2000 char long.

Merci Pierre.
We (Ljupčo or I) will get the information and put it here.

The result is : 2236

Thanks for getting back to us. Thatā€™s surprisingly large, as Azure tokens are usually about 52 chars long. Is this token encoded? Whatā€™s the length of the key you used to encode it?

Merci Pierre pour ton aide.

If the token is removed, upgrade passesā€¦

So we will remove it and import a new token after the upgrade

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