Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-10215

DB migration #1642 may fail with IllegalStateException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.4, 6.5, 6.6, 6.7
    • Fix Version/s: 6.7.2, 7.0
    • Component/s: Database
    • Labels:
      None

      Description

      Database migration 1642 (SonarQube 6.4) fails under specific circonstances with the following IllegalStateException

      2017.12.15 08:50:59 ERROR web[][DbMigrations] #1642 'Support private project in default permission template': failure | time=6ms
      2017.12.15 08:50:59 ERROR web[][DbMigrations] Executed DB migrations: failure | time=1033080ms
      2017.12.15 08:50:59 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=1033204ms
      2017.12.15 08:50:59 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 #1642 'Support private project in default permission template' 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.util.Iterator.forEachRemaining(Unknown Source)
      	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
      	at java.util.stream.ReferencePipeline$Head.forEachOrdered(Unknown Source)
      	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:50)
      	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.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.IllegalStateException: Permission template with uuid default_template_for_views not found
      	at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
      	at org.sonar.server.platform.db.migration.version.v64.SupportPrivateProjectInDefaultPermissionTemplate.getPermTemplateId(SupportPrivateProjectInDefaultPermissionTemplate.java:115)
      	at org.sonar.server.platform.db.migration.version.v64.SupportPrivateProjectInDefaultPermissionTemplate.readOrganizationProperties(SupportPrivateProjectInDefaultPermissionTemplate.java:104)
      	at org.sonar.server.platform.db.migration.version.v64.SupportPrivateProjectInDefaultPermissionTemplate.execute(SupportPrivateProjectInDefaultPermissionTemplate.java:50)
      	at org.sonar.server.platform.db.migration.step.DataChange.execute(DataChange.java:39)
      	at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
      	... 11 common frames omitted
      

      This error has been reported on the mailing list, as part of an upgrade from 5.6.7 to 6.7 LTS

      Analysis

      DB migration #1604 is looking for the permission template for views which UUID is stored in column ORGANIZATION.DEFAULT_PERM_TEMPLATE_VIEW but this permission template does not exist.

      This column is populated in DB migration #1509 (SonarQube 6.3) from the property sonar.permission.template.VW.default. It seems the property exists, it has a value but the template it references does not.

      Workaround

      Set column ORGANIZATION.DEFAULT_PERM_TEMPLATE_VIEW to null and restart the DB migration
      Confirmed working on Oracle with statement update ORGANIZATIONS set default_perm_template_view = null;, see https://groups.google.com/d/msg/sonarqube/CMM9wVWUn1A/LZ2g6GoaCgAJ

      Fix

      DB migration #1509 should ensure the permission template exists before copying the value from the property to the ORGANIZATION table

        Attachments

          Activity

            People

            • Assignee:
              sebastien.lesaint Sebastien Lesaint
              Reporter:
              sebastien.lesaint Sebastien Lesaint
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: