Troubleshooting Elasticsearch-related issues
Recovering from Elasticsearch read-only indices
You may encounter issues with Elasticsearch (ES) indices becoming locked in read-only mode. ES requires free disk space available and implements a safety mechanism to prevent the disk from being flooded with index data that:
- locks all indices in read-only mode when the 95% used disk usage watermark is reached.
ES shows warnings in the logs as soon as disk usage reaches 85% and 90%. At 95% usage and above, indices turning read-only causes errors in the web and compute engine.
Freeing disk space will not automatically make the indices return to read-write. To make indices read-write, you also need to:
- restart SonarQube Community Build.
SonarQube Community Build's built-in resilience mechanism allows SonarQube Community Build to eventually recover from the indices being behind data in the DB (this process can take a while).
If you still have inconsistencies, you'll need to rebuild the indices (this operation can take a long time depending on the number of issues and components):
- Stop SonarQube Community Build.
- Delete the
data/es8
directory. - Restart SonarQube Community Build.
Failed background tasks during reindexing
During Elasticsearch reindexing, you may have failed tasks in your branches or pull requests:
- If you only have a few failed tasks, you can reanalyze your branch or pull request. You may want to use web services to remove branches and pull requests that can't be reanalyzed because they have been removed from version control.
- If you have many failed tasks, you may want to delete your Elasticsearch directory and reindex again. To do so, see Forcing an Elasticsearch reindex on the Reindexing page.
If background tasks of type Project Data Reload fail for a particular project, see Reindexing a single project on the Reindexing page.
Exception java.lang.RuntimeException: cannot run elasticsearch as root
SonarQube Community Build starts an Elasticsearch process, and the same account that is running SonarQube Community Build itself will be used for the Elasticsearch process. Since Elasticsearch cannot be run as root, that means SonarQube Community Build can't be either. You must choose some other, non-root account with which to run SonarQube Community Build, preferably an account dedicated to the purpose.
Related pages
Was this page helpful?