The table project_measures is purged during analysis so that the past measures on files, and optionally directories, are deleted and keeps size of table under control.
Since version 6.0, the measures on unit test files are never purged. That generates a significative amount of unused data. For example on https://next.sonarqube.com/sonarqube, the table has 16.4M rows, distributed in:
- 1.5M rows for "last" measures, including 1.1M for main and test files
- 14.8M rows to past measures, including
- 0.2M rows for main files
- 9.5M rows for test files ---> this is the data leak.
This ticket aims to fix the leak: correctly remove file measures when purging an analysis. Managing removal of existing past file measures is not part of the fix in order to minimize DB migration duration on a patch. If needed the following SQL request can be executed in background while SonarQube is up: