[GRADLE-2699] Gradle wrapper race condition when concurrently executing Created: 07/Mar/13 Updated: 25/Mar/13 Resolved: 25/Mar/13 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 1.4 |
Fix Version/s: | 1.6-rc-1 |
Type: | Bug | ||
Reporter: | Gradle Forums | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Description |
We've been getting errors such as this from the Gradle Wrapper quite frequently when running Gradle builds on cloudbees CI: [1]https://vertx.ci.cloudbees.com/job/ve... I decided to look at the code in the Gradle Wrapper to see what it was doing around this time, and I noticed a possible race condition that could be causing the problem: [2]https://github.com/gradle/gradle/blob... If two or more builds are running as the same user on the same machine at the same time (which is normal in a CI environment), then it appears two or more builds could end up trying to unzip the distribution at the same time and deleting the tmp file from under the feet of the other one. I haven't tried to debug this - this is just a guess looking at some suspicious code. |
Comments |
Comment by Gradle Forums [ 07/Mar/13 ] |
One way of fixing this would be to generate the temp download file name using a random UUID to (virtually) eliminate the possibility of clashes, then use an atomic rename to rename the file (if it doesn't already exist) when the download is complete: [1]http://docs.oracle.com/javase/7/docs/..., java.nio.file.Path, java.nio.file.CopyOption...) |