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?

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(
                at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(
                at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(
                at org.sonar.server.platform.db.migration.engine.MigrationEngineImpl.execute(
                at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doUpgradeDb(
                at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doDatabaseMigration(
                at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
                at java.base/java.util.concurrent.ThreadPoolExecutor$
                at java.base/
Caused by: String or binary data would be truncated.
                at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(
                at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(
                at org.sonar.server.platform.db.migration.step.UpsertImpl.execute(
                at org.sonar.server.platform.db.migration.version.v81.MigrateAzureAlmSettings.insertAlmSetting(
                at org.sonar.server.platform.db.migration.version.v81.MigrateAzureAlmSettings.loadOrInsertAlmSettings(
                at org.sonar.server.platform.db.migration.version.v81.MigrateAzureAlmSettings.execute(
                at org.sonar.server.platform.db.migration.step.DataChange.execute(
                at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(
                ... 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.