Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy
https://codechecker.readthedocs.io
Apache License 2.0
2.15k stars 358 forks source link

Add a `db_cleanup` routine that updates the cached `CONFIG.products.num_of_runs` to the actual, sensible, value #4199

Open whisperity opened 3 months ago

whisperity commented 3 months ago

As of CodeChecker 6.23, the following nonsense can appear for long-running servers. The underlying reason is so far unclear, which makes it non-trivial to fix, but we could at least temporarily treat the symptoms at every server restart if a db_cleanup routine was added that updates the value cached in the CONFIG database under products.num_of_runs to the real value of COUNT(runs.id) in the PRODUCT database.

A snippet of the home page showing a negative number of runs.

[!WARNING] In the post-#4171 world, care must be taken that this calculation and update can not be executed in parallel and must be sequenced after the per-product db_cleanup.


[!TIP] We should also consider that this calculation could be updated not just every time a server restarts, but every time the details of a product are queried. In case we detect that there is a negative number of runs, we could defer to a "cold path" where the calculation of the actual number of runs is performed, and the database is updated. (While more expensive, the trade-off is that we will never actually give the user back a nonsense.)