Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Concurrent restore of project.json contention on lock.json #1682

Closed
ericstj opened this issue Apr 21, 2015 · 4 comments
Closed

Concurrent restore of project.json contention on lock.json #1682

ericstj opened this issue Apr 21, 2015 · 4 comments
Milestone

Comments

@ericstj
Copy link

ericstj commented Apr 21, 2015

Our build happens to try to restore project.json from two separate threads/processes. This can result in an IOException when trying to write the .lock.json.

ericstj added a commit to ericstj/buildtools that referenced this issue Apr 21, 2015
DNX has an issue with concurrent restore: aspnet/dnx#1682

Previously I would workaround by copying to intermediate, but this breaks in official build where intermediate is not under the scope of our nuget.config, so custom package sources are ignored.

Fix this instead by wrapping the call to dnu restore with a mutex unique to the project.json name.  We only need to do this for the test project.json because that is the only one we'll restore concurrently.
@muratg muratg added this to the 1.0.0-beta5 milestone Apr 24, 2015
@pranavkm
Copy link
Contributor

@ericstj, do you have the stack trace for the error?

@ericstj
Copy link
Author

ericstj commented Apr 27, 2015

Here you go. I forced it by dropping 6 projects in the same directory with different csproj's and same project.json.

System.IO.IOException: The process cannot access the file 'd:\corefx\src\Microsoft.CSharp\src\project.lock.json' because it is being used by another process. (TaskId:14)
   at System.IO.Win32FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs) (TaskId:14)
   at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent) (TaskId:14)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) (TaskId:14)
   at Microsoft.Framework.Runtime.DependencyManagement.LockFileFormat.Write(String filePath, LockFile lockFile) (TaskId:14)
   at Microsoft.Framework.PackageManager.RestoreCommand.WriteLockFile(String projectLockFilePath, Project project, List`1 graphItems, PackageRepository repository, IEnumerable`1 frameworks) (TaskId:14)
   at Microsoft.Framework.PackageManager.RestoreCommand.<RestoreForProject>d__75.MoveNext() (TaskId:14)
--- End of stack trace from previous location where exception was thrown --- (TaskId:14)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) (TaskId:14)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) (TaskId:14)
   at Microsoft.Framework.PackageManager.RestoreCommand.<>c__DisplayClass74_0.<<ExecuteCommand>b__0>d.MoveNext() (TaskId:14)
--- End of stack trace from previous location where exception was thrown --- (TaskId:14)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) (TaskId:14)
   at Microsoft.Framework.PackageManager.RestoreCommand.<ExecuteCommand>d__74.MoveNext() (TaskId:14)
---------- (TaskId:14)
Restore failed (TaskId:14)
The process cannot access the file 'd:\corefx\src\Microsoft.CSharp\src\project.lock.json' because it is being used by another process. (TaskId:14)

@pranavkm
Copy link
Contributor

cc @anurse

@davidfowl
Copy link
Member

So we're not supporting this. But we're going to fail better

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants