Bug: 'file not found' is cached and not checked again

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    • SonarQube Enterprise 9.7.1
    • sonar-scanner 4.7.2747
  • what are you trying to achieve
    • Scan the code with server side caching using the Sonar CFamily scanner.
  • what have you tried so far to achieve this
    • I tried to prune some libraries in our Docker, but I accidentally pruned too many, including the Eigen library for example.
    • This lead to worse analysis results and a lot of ‘file not found’ logs
    • After using the Docker with all the libraries again, all the unchanged files show a cache hit (server side cache).
    • The cache hit was generated with the faulty analysis with the file not found. (see log)
    • I can’t find anywhere where the server side cache can be manually cleared.
    • If a file is not found this should be part of cache invalidation, so this is a bug in SonarQube server side caching. I.e. SonarQube should check if files that where missing for a cache hit can be found now.
14:07:47.388 INFO: Cache hit for: /some/redacted.cpp
14:07:47.389 DEBUG: [main] /some/redacted.h:18 'Eigen/Core' file not found

Hi @Carl,

What you are describing indeed sounds like a bug.

I will try to reproduce it and get back to this thread.

As a workaround to clear the cache, you can change one analysis configuration that impacts the results. For example:

  • by enabling/disabling one rule.
  • or if you want to do it from the command line, you can add one new option like -Dsonar.cfamily.reportingCppStandardOverride=c++20

Both approaches will clear the cache since they invalidate the results of all files.

Thanks,

Hi @Abbas,

thank you for the workaround, I’ll use that for now.

Maybe it would be good to add a -Dsonar.cfamily.clearServerCache=true in the future, so that this can be done properly. As we all know cache invalidation is one of the hardest problems in computer science, and it’s always good to have a manual escape hatch here.

Best regards,

Carl

Hi @Carl,

I was able to reproduce and I created this ticket: [CPP-4037] - Jira
Fair point about the option to clear the cache. We added a hidden one to disable the cache in case of a bug but we missed the fact that it isn’t straightforward to clear the server cache.

Thanks,

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.