AccessDeniedException with parallel analysis and default ~/.sonar cache


I’m running multiple parallel analysis (in bunch of ~10) of java and C++ projects on Jenkins with Linux and Windows agents.

Java 11.0.3 AdoptOpenJDK (64-bit)
Windows Server 2019 10.0 amd64
User cache: C:\Users\s.yggbuild.sonar\cache
SonarQube 8.1

On Windows Java analysis fail with error:

**Error during SonarScanner execution**
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(
**Caused by: java.lang.IllegalStateException: Fail to move** C:\Users\s.yggbuild\.sonar\cache\_tmp\fileCache10862709070534572633.tmp to C:\Users\s.yggbuild\.sonar\cache\0816184471131ebed73ed8f48b9bbc8e\sonar-scanner-engine-shaded-
Caused by: java.nio.file.AccessDeniedException: C:\Users\s.yggbuild\.sonar\cache\_tmp\fileCache10862709070534572633.tmp -> C:\Users\s.yggbuild\.sonar\cache\0816184471131ebed73ed8f48b9bbc8e\sonar-scanner-engine-shaded-

C++ scans are instead always successful.

Interestingly, parallel scans run without problems on Linux agents.

I did not find anything against the parallel analysis execution in the documentation.

If this is a BUG, Is there anything you can suggest that may let use the cache in this situation?

As a workaround I though to use a different cache for each project, but unfortunately this is not possible due to the cache size and the total amount of projects to be scanned (358M x 100).

Any help would be appreciated !



Welcome to the community!

The failing analysis appears to run on a Windows box. Couple that with your AccessDeniedException and I’m going to point the finger at Windows Defender or a virus scanner. We recommend that on analysis machines you turn off “helpful” processes that lock files and change file perms for just this reason.


Hi Ann,

according to you this is not a race condition issue caused by the parallel execution of multiple analyses. Is the cache designed to handle parallel executions?

We will have a look at the Windows box, there might be something else which locks files in the .sonar cache.



I see your point. I was overlooking the fact that the cache is in a user directory and focusing on Windows & the error type.

Yes, to my knowledge, parallel analyses should work just fine on the same build agent. As you noted, it seems to work fine on Linux. Really, I would start by disabling all those “helpful” Windows processes first. And to be sure, I would either delete the existing cache (so it’s re-created) or double-check/reapply proper permissions on it recursively.