Failed to load quality profiles - Sonarqube docker container

We have been running sonarqube via the 8.9.4 lts-developer container image. It was working fine until a few days ago when it suddenly started throwing errors during scans. I have run with -X flag applied and provided the truncated logs below

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar (default-cli) on project backend: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher: Unable to load component class org.sonar.api.batch.rule.internal.DefaultActiveRules: Failed to load quality profiles: unexpected end of stream -> [Help 1]
...
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar (default-cli) on project backend: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher
...
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher
...
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.rule.internal.DefaultActiveRules
...
Caused by: java.lang.IllegalStateException: Failed to load quality profiles
...
Caused by: java.net.ProtocolException: unexpected end of stream

The scan worked fine on one push, and then failed on another 20 mins later that made no changes to sonarqube, so I am confused as to what has caused it. We have not got around to setting up a dedicated database for the server yet and are still using the embedded one. Could this be causing the issue?

Other than restarting the container I have not tried anything else as I am not sure what else could resolve the issue.

Thanks

Hi @astump
welcome to the community!

I can share hints about what is happening but without the full logs from both sides (scanner and SonarQube), it’s difficult to provide you with a definitive answer. The -X scanner parameter activates DEBUG logs; but you only shared (partially) a single log at ERROR level.

There are two known causes for such problem:

  • Network connectivity (certificates, proxy, address…), to check your connectivity you may look for the scanner requests in the SonarQube server access.log file, then your proxy logs.
  • ElasticSearch index corruption. This is also a likely root cause for such problem. If the case you would solve it by removing the ES data so that SonarQube recreates it:
    • stop your SonarQube instance
    • remove the /opt/sonarqube/data/es7 folder (or recreate the docker sonarqube_data volume)
    • start SonarQube

And let us know.

Embedded H2 DB:
The embedded H2 database is only suitable for throw-away test instances; it provides no upgrade nor export path for your SonarQube data. If you intend to keep any data from a SonarQube instance, you shall use an external DB (and on docker it’s very easy to define one).