Sonarqube upgrade database migration

We are currently using Sonarqube 7.9lts-community. We have a Postgresql 10.15 database. We would like to upgrade Sonarqube to 8.6. We are using Openshift as well. I have created an instance of Sonarqube 8.6 and pointed it at our existing database. I went to the Sonarqube url/setup and tried to run that. On that page, it says that it cannot establish a database connection after about a second. When investigating the logs of the Sonarqube pod I found some other errors. This is a very abridged stack trace:

    2021.01.07 19:25:49 INFO  web[][o.s.s.p.d.m.DatabaseMigrationImpl] Starting DB Migration and container restart
    2021.01.07 19:25:49 INFO  web[][DbMigrations] Executing DB migrations...
    2021.01.07 19:25:49 INFO  web[][DbMigrations] #3433 'Populate 'uuid' column for 'PROJECT_MEASURES''...
    2021.01.07 19:25:50 ERROR web[][DbMigrations] #3433 'Populate 'uuid' column for 'PROJECT_MEASURES'': failure | time=528ms
    2021.01.07 19:25:50 ERROR web[][DbMigrations] Executed DB migrations: failure | time=602ms
    2021.01.07 19:25:50 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=1049ms
    2021.01.07 19:25:50 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 #3433 'Populate 'uuid' column for 'PROJECT_MEASURES'' failed

Caused by: java.sql.BatchUpdateException: Batch entry 221 update project_measures set uuid = 'AXbeT_JG-lkp_dpk2EZ8' where id = 123135 was aborted: ERROR: unexpected data beyond EOF in block 202 of relation base/16385/19991

Really not sure what any of this means and I am having trouble finding any help. Any help would be appreciated.

Thanks Much!

Hi, That looks definitely like an internal PostgreSQL error. Do you host it yourself? Can you access the PostgreSQL logs? I expect you to find the same error there. On What OS (+version) is hosted this database?

Resources online suggest that it may be linked with a kernel bug and that you need to patch your operating system. Or to increase the max_wal_size memory settings in PostgreSQL.

We are trying to upgrade our SonarQube instance from 7.9.2 to 8.6 and we are running into the following error when we perform the DB migration step from SonarQube setup page:

org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #3433 'Populate 'uuid' column for 'PROJECT_MEASURES'' failed

Caused by: java.lang.IllegalStateException: Error during processing of row: [id=41694]

Caused by: java.sql.BatchUpdateException: Batch entry 90 update project_measures set uuid = 'AXdFzEY81-dhw8GcsuOy' where id = 37539 was aborted: ERROR: unexpected data beyond EOF in block 475 of relation base/16385/25314

Caused by: org.postgresql.util.PSQLException: ERROR: unexpected data beyond EOF in block 475 of relation base/16385/25314

  Hint: This has been seen to occur with buggy kernels; consider updating your system.

(We are on the most recent OS patch as of last month)

We notice the error when performing the following steps.

  1. Start with SQ 7.9.2 with PostgreSQL 10 DB (our current verison)
  2. Upgrade to the latest lts version - 7.9.5
  3. Upgrade to SQ 8.2, perform DB migration via SQ setup page, works
  4. Upgrade to SQ 8.6, can’t get passed the DB migration step, get the error above.

We have increased the “max_wal_size” in our PostgreSQL instance, which helped us to have much better success with upgrading from 7.9.2 to 8.2 (we were experiencing EOF errors there too).

While researching this issue, we decided to check the “project_measures” table in the DB itself. In 7.9.2, we noticed that there is no “uuid” column at all. However, in 8.2, there is. Upon further examination, we noted that out of ~72000 rows in the “project_measures” table in 8.2, about 90% of them have a null uuid.

Are we missing a step in the upgrade process? Do we need to upgrade to the other 7.9.x versions before going to 8.2? We also noticed there is no 8.0 or 8.1 version available in the https://hub.docker.com/_/sonarqube/?tab=tags&page=1&ordering=last_updated

Any help would be greatly appreciated.