Randomly missing files in Sonar Analysis

Hi SonarQube team,

I have an issue with our company instance of SonarQube (Data Center Edition, Version 8.9.6 (build 50800)). I am using it for an C++ analysis using commercial C++ plugin.
I am running the analysis on pool of Bamboo agents (15 Agents - Windows server 2016). I noticed sometimes analyzer misses most of the cpp files, which results to this:


When I checked the logs, I noticed this diff:

Here is a full log:
FullVsMissing.zip (501.4 KB)

I have selected a run, which was running on same agent, therefore PC environment should not be a factor. It is also not executed on same commit (Right one has added one commit, but this is also not a factor).

When I checked analysis report, I see a major diff in coverages-xxx.pb (Lot of them missing), issues-xxx.pb (Lot of them missing), measures-xxx.pb (All are present, but there is a diff) and symbols-xxx.pb (Lot of them missing).
Measures-xxx.pb always looks like this:

Here is a complete folder diff report:
FolderCompare.zip (92.8 KB)

I cannot attach a full diff, because I see there are complete source files. But I hope you will be able to help me even without this.
Thanks in advance,
Michal Cermak

Hello @Michal_Cermak,

We would need more information to understand what may be happening. First, do you use the build wrapper or a compilation database? Could you send us the relevant file (build-wrapper-dump.json and build-wrapper.log of the compilation database itself) in both situations?

If you use the build wrapper, are you sure you only execute it on a full (= non-incremental) build of your code?

Thank you!

Here are requested log files. It is build on same machine from same inputs (Sources, projects):
MissingAnalysis.zip (899.4 KB)

It is visible that those logs are significantly smaller in failed case.
As you can see from logs, I am using VS + Build wrapper. Compilation cmd is containing the /rebuild flag:
“C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe” Src\Titan.sln /t:Rebuild /p:Configuration=Debug /p:Platform=“x86” -maxcpucount

Issue might be, that I am combining x86 and x64 under under x86 solution setup. I noticed this is calling different CL.exe (x64\CL.exe vs x86\CL.exe) and build wrapper might have an issue with it:

Thanks,
Michal Cermak

Hello @Michal_Cermak,

When looking at the log, I see that MsBuild is launched with the /nodeReuse:true flag, which means that instead of launching a new MsBuild process all the time (which the build wrapper could correctly track), it may reuse a previously launched one, and this previously launched process would be invisible from the build wrapper.

We already have a ticket to improve user experience here, but I would just advice that you disable node reuse (if you do it on the entry point, it should be forwarded to all the MsBuild sub-processes).

If this is not sufficient to solved the issue, I will need new logs when this reuse is disabled to see if there are other sources of randomness.

Thank you for the feedback @JolyLoic . I run about 30 analysis and none of them showed this issue. In the past about 20% of analysis runs ended up with this missing analysis.

Therefore I was really lucky or you really hit the root cause :slight_smile:

Can you (SonarQube team) add this msbuild switch to the build-wrapper guides? I have not found it anywhere and I guess this might be an issue happening to lot of developers who uses VS + build wrapper.

I really appreciate you help.

Yes, this should be better documented, I just created a ticket for that.

Hopefully, node reuse should not cause trouble for people that start a new VM for each analysis, but I don’t foresee any measurable harm in deactivating node reuse in all cases.

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