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

Indexing project measures index is failing when projects contain some old data

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.4
    • Component/s: ElasticSearch
    • Labels:

      Description

      Context

      Indexing project measures index at startup can fail when some projects haven't been analyzed since a long time and contains old data.

      For instance it will fail on project that contains measure on 'last_commit_date' when it was stored using a string format ("2010-12-20")), as this measure is now stored as a long.

      Stacktrace :

      2017.04.12 14:23:14 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] Container restart failed | time=1165714ms
      2017.04.12 14:23:14 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] Container restart failed
      java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Fail to execute request to select measures of project 5c40f27a-d455-4b6e-ae46-1754f407cfeb, analysis AVtiEIF_bUSm9CIrPq8q
      	at com.google.common.base.Throwables.propagate(Throwables.java:160)
      	at org.sonar.server.es.BaseIndexer.index(BaseIndexer.java:68)
      	at org.sonar.server.es.BaseIndexer.index(BaseIndexer.java:73)
      	at org.sonar.server.es.IndexerStartupTask.execute(IndexerStartupTask.java:84)
      	at java.util.Optional.ifPresent(Optional.java:159)
      	at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:71)
      	at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:45)
      	at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:67)
      	at org.sonar.server.platform.Platform.executeStartupTasks(Platform.java:188)
      	at org.sonar.server.platform.Platform.doStart(Platform.java:101)
      	at org.sonar.server.platform.Platform.doStart(Platform.java:79)
      	at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doRestartContainer(DatabaseMigrationImpl.java:137)
      	at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doDatabaseMigration(DatabaseMigrationImpl.java:106)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Fail to execute request to select measures of project 5c40f27a-d455-4b6e-ae46-1754f407cfeb, analysis AVtiEIF_bUSm9CIrPq8q
      	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
      	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
      	at com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:137)
      	at org.sonar.server.es.BaseIndexer.index(BaseIndexer.java:66)
      	... 14 common frames omitted
      Caused by: java.lang.IllegalStateException: Fail to execute request to select measures of project 5c40f27a-d455-4b6e-ae46-1754f407cfeb, analysis AVtiEIF_bUSm9CIrPq8q
      	at org.sonar.db.measure.ProjectMeasuresIndexerIterator.selectMeasures(ProjectMeasuresIndexerIterator.java:204)
      	at org.sonar.db.measure.ProjectMeasuresIndexerIterator.doNext(ProjectMeasuresIndexerIterator.java:185)
      	at org.sonar.db.measure.ProjectMeasuresIndexerIterator.doNext(ProjectMeasuresIndexerIterator.java:54)
      	at org.sonar.core.util.CloseableIterator.bufferNext(CloseableIterator.java:96)
      	at org.sonar.core.util.CloseableIterator.hasNext(CloseableIterator.java:87)
      	at org.sonar.server.measure.index.ProjectMeasuresIndexer.doIndex(ProjectMeasuresIndexer.java:99)
      	at org.sonar.server.measure.index.ProjectMeasuresIndexer.doIndex(ProjectMeasuresIndexer.java:92)
      	at org.sonar.server.measure.index.ProjectMeasuresIndexer.doIndex(ProjectMeasuresIndexer.java:61)
      	at org.sonar.server.es.BaseIndexer.lambda$index$0(BaseIndexer.java:60)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	... 3 common frames omitted
      Caused by: java.lang.IllegalArgumentException: Measure has no value
      	at org.sonar.db.measure.ProjectMeasuresIndexerIterator.readMeasure(ProjectMeasuresIndexerIterator.java:223)
      	at org.sonar.db.measure.ProjectMeasuresIndexerIterator.selectMeasures(ProjectMeasuresIndexerIterator.java:200)
      	... 13 common frames omitted
      

      Technical solution

      The project measures index is used to search measures and to display facets in the "Projects" page : as the list of metrics to be used is well defined, we should only load a white list of metrics key, which would fix this issue and even more it will reduce the size if this index.

      Alternate fix to do : The error "Measure has no value" should contains more information about the error : which project, component, metric, etc.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                simon.brandhof Simon Brandhof
                Reporter:
                julien.lancelot Julien Lancelot
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: