Sonarqube crash with "Duplicate key cpp/Sonar way"

Hello,

summary

We are running a trial on SonarQube Developer Edition and we are running SonarQube in a Docker container. We are however having our SonarQube crashing with these lines below as the last logs.

versions used (SonarQube, Scanner, Plugin, and any relevant extension)

SonarQube 7.4.0.18908 Developer Edition
Postgres 9.6.8

error observed (wrap logs/code around triple quote ``` for proper formatting)

Instance crashing with:

...
2019.01.31 18:08:03 INFO  web[][com.sonarsource.C.H] Loaded virtual plugin License for SonarLint
2019.01.31 18:08:03 INFO  web[][o.s.s.s.GeneratePluginIndex] Generate scanner plugin index
2019.01.31 18:08:03 INFO  web[][o.s.s.s.RegisterPlugins] Register plugins
2019.01.31 18:08:03 INFO  web[][o.s.s.s.RegisterMetrics] Register metrics
2019.01.31 18:08:04 INFO  web[][o.s.s.r.RegisterRules] Register rules
2019.01.31 18:08:17 INFO  web[][o.s.s.q.BuiltInQProfileRepositoryImpl] Load quality profiles
2019.01.31 18:08:17 INFO  web[][o.s.s.q.RegisterQualityProfiles] Register quality profiles
2019.01.31 18:08:17 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
java.lang.IllegalArgumentException: Duplicate key cpp/Sonar way
	at org.sonar.core.util.stream.MoreCollectors.putAndFailOnDuplicateKey(MoreCollectors.java:295)
	at org.sonar.core.util.stream.MoreCollectors.lambda$uniqueIndex$9(MoreCollectors.java:256)
	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at org.sonar.server.qualityprofile.RegisterQualityProfiles.loadPersistedProfiles(RegisterQualityProfiles.java:111)
	at org.sonar.server.qualityprofile.RegisterQualityProfiles.start(RegisterQualityProfiles.java:83)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
	at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
	at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
	at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
	at org.picocontainer.behaviors.Stored.start(Stored.java:110)
	at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
	at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
	at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)
	at org.sonar.server.platform.platformlevel.PlatformLevelStartup.access$001(PlatformLevelStartup.java:46)
	at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:82)
	at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:46)
	at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:79)
	at org.sonar.server.platform.Platform.executeStartupTasks(Platform.java:196)
	at org.sonar.server.platform.Platform.access$400(Platform.java:46)
	at org.sonar.server.platform.Platform$1.lambda$doRun$1(Platform.java:121)
	at org.sonar.server.platform.Platform$AutoStarterRunnable.runIfNotAborted(Platform.java:371)
	at org.sonar.server.platform.Platform$1.doRun(Platform.java:121)
	at org.sonar.server.platform.Platform$AutoStarterRunnable.run(Platform.java:355)
	at java.lang.Thread.run(Thread.java:748)
2019.01.31 18:08:18 INFO  web[][o.s.p.StopWatcher] Stopping process
2019.01.31 18:08:20 INFO  app[][o.s.a.SchedulerImpl] Process [web] is stopped
2019.01.31 18:08:20 INFO  app[][o.s.a.SchedulerImpl] Process [es] is stopped
2019.01.31 18:08:20 WARN  app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 143
2019.01.31 18:08:20 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped

steps to reproduce

Install SonarQube 7.4.0.18908, watch logs.

Hi,
Could you list the plugins that you have installed in SonarQube?

sonar-auth-saml-plugin-1.1.0.181
sonar-gitlab-plugin-4.0.0

So,

It’s possible that this was due to a database corruption.
We tried to upgrade SonarQube to 7.5.x and got the same issue.

We created a new database and are no longer seeing this.

Will update once we’ve confirmed that was the case.

Yes, it was likely a DB corruption: Looks like there 2 built in quality profiles with the same language and name.
This is obviously unexpected so we would need to know the exact steps taken to reach that situation and also the full list of plugins (including analyzers) that you had installed.

1 Like

This was an empty instance that we were using as a staging environment.

We did not really have any data, we followed the upgrade process mentioned in /setup each time.

The list of plugins we have are:

Git
Git SCM Provider for SonarQube
1.6.0.1349

GitLab
GitLab Plugin for Reporting
4.0.0

JaCoCo
JaCoCo XML report importer
1.0.1 (build 143)

LDAP
Delegates authentication to LDAP
2.2 (build 608)

SAML 2.0 Authentication for SonarQube
1.1.0 (build 181)

SonarC#
Code Analyzer for C#
7.7 (build 7192)

SonarCSS
Code Analyzer for CSS
1.0.2 (build 611)

SonarFlex
Code Analyzer for Flex / ActionScript
2.4 (build 1222)

SonarGo
Code Analyzer for Go
1.1.0 (build 1612)

SonarJS
Code Analyzer for JavaScript
5.0 (build 6962)

SonarJava
Code Analyzer for Java
5.8 (build 15699)

SonarKotlin
Code Analyzer for Kotlin
1.2.1 (build 2009)

SonarPHP
Code Analyzer for PHP
2.14.0.3569

SonarPython
Code Analyzer for Python
1.10 (build 2131)

SonarRuby
Code Analyzer for Ruby
1.2.1 (build 2009)

SonarTS
Code Analyzer for TypeScript
1.8 (build 3332)

SonarVB
Code Analyzer for VB.NET
7.7 (build 7192)

SonarXML
Code Analyzer for XML
1.5.1 (build 1452)

Svn
Subversion SCM Provider for SonarQube
1.9.0.1295