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

Fail to migrate to 7.9 when there are 2 quality gate conditions on the same metric

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.9.2
    • Component/s: Database, Quality Gate
    • Labels:
      None
    • Edition:
      Community
    • Production Notes:
      None

      Description

      Description

      In SonarQube 7.6, Quality Gate have been simplified. During this simplification, a DB migration have been done in order to clean up no more valid conditions.

      Unfortunately, a use case have been forgotten : in SonarQube 6.7, it was possible to have 2 conditions on the same metric : one condition on the overall value, and one condition using "Over Leak Period" checkbox.

      This use case prevent any migration and will fail with :

      2019.10.25 19:01:24 INFO  web[ ][DbMigrations] #2506 'Migrate quality gate conditions using warning, period and no more supported operations'...
      2019.10.25 19:01:24 ERROR web[ ][DbMigrations] #2506 'Migrate quality gate conditions using warning, period and no more supported operations': failure | time=24ms
      2019.10.25 19:01:24 ERROR web[ ][DbMigrations] Executed DB migrations: failure | time=104488ms
      2019.10.25 19:01:24 ERROR web[ ][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=104623ms
      2019.10.25 19:01:24 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 #2506 'Migrate quality gate conditions using warning, period and no more supported operations' 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.IllegalArgumentException: Duplicate key blocker_violations
      	at org.sonar.core.util.stream.MoreCollectors.putAndFailOnDuplicateKey(MoreCollectors.java:299)
      	at org.sonar.core.util.stream.MoreCollectors.lambda$uniqueIndex$9(MoreCollectors.java:260)
      	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
      	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
      	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
      	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
      	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
      	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
      	at org.sonar.server.platform.db.migration.version.v76.MigrateNoMoreUsedQualityGateConditions.markConditionsUsingLeakPeriodHavingAlreadyRelatedConditionAsToBeDeleted(MigrateNoMoreUsedQualityGateConditions.java:170)
      	at org.sonar.server.platform.db.migration.version.v76.MigrateNoMoreUsedQualityGateConditions.execute(MigrateNoMoreUsedQualityGateConditions.java:109)
      	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
      2019.10.25 19:09:00 INFO  web[ ][o.s.p.ProcessEntryPoint] Gracefully stopping process
      

      Workaround

      Waiting for a fix, users need to restore their backup and to remove conditions on same metrics in all quality gates.

       

        Attachments

          Activity

            People

            • Assignee:
              julien.lancelot Julien Lancelot
              Reporter:
              julien.lancelot Julien Lancelot
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: