Search code examples
sonarqubesonar-runnersonarqube5.1

Recover from sonarrunner leaving DB in inconsistent state


Sonar maven plugin run has failed due to lack of memory. I was trying to run it against one module to debug something...

[INFO] [16:16:07.709] Execute PMD 5.4.0 done: 10861 ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:07 min
[INFO] Finished at: 2015-12-30T16:16:08+01:00
[INFO] Final Memory: 76M/953M
[INFO] ------------------------------------------------------------------------
---------------------------------------------------
constituent[0]: file:/usr/share/maven3/lib/wagon-http-2.6-shaded.jar
[SNIP...]
constituent[39]: file:/usr/share/maven3/conf/logging/
---------------------------------------------------
Exception in thread "main" 
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"

Now, when I try to run sonar on all modules it tells me: The project 'foo:module1' is already defined in SonarQube but not as a module of project 'foo:aggregator'

But when I go to sonar:

  • there is no project foo:module1 on the list of all projects
  • when I open http://sonar.example/dashboard/index/foo:module1 it shows the module1 as a component of foo:aggregator
  • I see module1 listed in "Project Permissions" view

I tried running the analysis to completion hoping it will add the project, so that I can remove it later, but I got:

[INFO] [17:17:17.805] Execute decorators...
[WARN] [17:17:33.408] Too many components under resource 'module1'. DSM will not be displayed.
[INFO] [17:17:33.526] Store results in database
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:19 min
[INFO] Finished at: 2015-12-30T17:17:33+01:00
[INFO] Final Memory: 57M/1044M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project module1: Unable to save file sources:
[ERROR] ### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '34503e95-81ac-40bb-a73c-60325a11088c' for key 'file_sources_file_uuid_uniq'
[ERROR] ### The error may involve org.sonar.core.source.db.FileSourceMapper.insert-Inline
[ERROR] ### The error occurred while setting parameters
[ERROR] ### SQL: INSERT INTO file_sources (project_uuid, file_uuid, created_at, updated_at, binary_data, line_hashes, data_hash, src_hash)     VALUES (?, ?, ?,     ?, ?, ?,     ?, ?)
[ERROR] ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '34503e95-81ac-40bb-a73c-60325a11088c' for key 'file_sources_file_uuid_uniq'

How do I 'delete' the foo:module1 from sonar so that I can run the analysis on foo:aggregator


Solution

  • The best I could do was to remove the module1 using the Bulk Deletion That took all the module's data with it.

    So apparently you can hose your Sonar data just by executing the runner on a maven submodule. Way to go!