我们将Sonarqube更新为5.2版。之后,一些Java项目开始失败,并出现以下异常:
2015.12.22 02:42:13 INFO [o.s.s.c.s.ComputationStepExecutor] Execute component visitors | time=9942ms
2015.12.21 13:01:45 ERROR [o.s.s.c.t.CeWorkerRunnableImpl] Failed to execute task AVHFtA0KaMG72s7lWjEx
java.lang.IllegalArgumentException: Multiple entries with same key: MeasureKey{metricKey='lines', ruleId=-6253, characteristicId=-6253}=org.sonar.db.measure.PastMeasureDto@7493f7f3 and MeasureKey{metricKey='lines', ruleId=-6253, characteristicId=-6253}=org.sonar.db.measure.PastMeasureDto@1e7bae50
at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:150) ~[guava-17.0.jar:na]
at com.google.common.collect.RegularImmutableMap.checkNoConflictInBucket(RegularImmutableMap.java:104) ~[guava-17.0.jar:na]
at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:70) ~[guava-17.0.jar:na]
at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:254) ~[guava-17.0.jar:na]
at com.google.common.collect.Maps.uniqueIndex(Maps.java:1166) ~[guava-17.0.jar:na]
at com.google.common.collect.Maps.uniqueIndex(Maps.java:1140) ~[guava-17.0.jar:na]
at com.google.common.collect.FluentIterable.uniqueIndex(FluentIterable.java:424) ~[guava-17.0.jar:na]
at org.sonar.server.computation.step.ComputeMeasureVariationsStep$VariationMeasuresVisitor.setVariationMeasures(ComputeMeasureVariationsStep.java:145) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.step.ComputeMeasureVariationsStep$VariationMeasuresVisitor.computeMeasuresWithVariations(ComputeMeasureVariationsStep.java:124) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.step.ComputeMeasureVariationsStep$VariationMeasuresVisitor.visitAny(ComputeMeasureVariationsStep.java:115) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitNode(DepthTraversalTypeAwareCrawler.java:60) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:44) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:91) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:47) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.step.ComputeMeasureVariationsStep.execute(ComputeMeasureVariationsStep.java:92) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:39) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.taskprocessor.report.ReportTaskProcessor.process(ReportTaskProcessor.java:53) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.taskprocessor.CeWorkerRunnableImpl.executeTask(CeWorkerRunnableImpl.java:78) [sonar-server-5.2.jar:na]
at org.sonar.server.computation.taskprocessor.CeWorkerRunnableImpl.run(CeWorkerRunnableImpl.java:55) [sonar-server-5.2.jar:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.7.0_45]
at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.7.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [na:1.7.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_45]
at java.lang.Thread.run(Unknown Source) [na:1.7.0_45]
我在Sonar中安装了以下插件
答案 0 :(得分:2)
您似乎有一些损坏的过去措施,可能是由于在迁移过程中缺少分析或其他意外问题。
您必须清理数据库才能继续分析。 使用SonarQube 5.3,您将能够知道哪个组件已损坏过去的措施。
要查找要为给定组件删除的重复度量,您必须执行以下SQL查询(替换为组件的键):
SELECT s.id, pm.metric_id, pm.rule_id, pm.characteristic_id FROM project_measures pm
INNER JOIN snapshots s ON s.id=pm.snapshot_id
INNER JOIN projects p ON p.id=s.project_id AND p.kee='<COMPONENT_KEY>'
INNER JOIN metrics m ON m.id=pm.metric_id
WHERE m.name='lines'
AND pm.person_id IS NULL
GROUP BY s.id, pm.metric_id, pm.rule_id, pm.characteristic_id
HAVING count(*) > 1
然后,对于返回的每一行,执行以下查询(替换为s.id列的值等):
SELECT pm.* FROM project_measures pm
INNER JOIN snapshots s ON s.id=pm.snapshot_id
WHERE s.id=<S_ID> AND pm.metric_id=<PM_METRIC_ID> AND pm.rule_id=<PM_RULE_ID> AND pm.characteristic_id=<PM_CHARCTERISTIC_ID>
此查询应返回至少2行:它是使项目计算失败的重复数据。您需要通过删除其他行来保留一行:
DELETE FROM project_measures WHERE id=<PM_ID>
在删除某些数据之前,请小心备份数据库!
答案 1 :(得分:1)
对于type = DIRECTORY我们也有这个问题但是没有使用Julien的SQL查询找到重复的度量。解决方案是排除抛出异常中指示的每个目录。这是通过在排除列表中添加如下模式来完成的。
**/Implementations/Sales/**
分析成功完成后(可以进行多次运行),然后您可以从列表中删除排除项并再次运行。分析将成功完成,任何导致问题的内容都将被刷新。