baseclass / Contrib.Nuget

Extending nuget with nuget packages
MIT License
30 stars 21 forks source link

Fix concurrency issue regression #47

Open mnivet opened 6 years ago

mnivet commented 6 years ago

We recently upgrade Baseclass.Contrib.Nuget.Output package to support VS2017

However we discover that recent versions have a concurrency issue similar to the one I had fixed in the past.
Looking at the code it appears that a regression appear when the c# code has been moved from the targets file to a cs file in the c# project.
The mutex do not cover any more the read file operation but only the file extraction operation which cause concurrency issue when one try to read the file while one is currently extracting it which sometimes occurs on our build servers in CI.

The intend of this pull request is to fix that regression by re-introduce the file read operation inside the mutex.

I've also include the idea of issue #36 to improve performances in a concurrent build environment.

This is now running fine on our build servers with an internal pre-release package.

romerod commented 6 years ago

Thanks for the pull request.

Why did you remove the existence of the file before creating the mutex? There is no need to create it when the file is already there.

mnivet commented 6 years ago

The file can be there but not fully written by one execution which unzip it. So expecting we can read the file just because it is present is wrong. It's the issue that occurs sometime on our build server where we intensively parallelize builds