-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Lock scratch directory during tool execution #7269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Currently, concurrent execution of SwiftPM can easily break the state in .build irreparably. This is especially in conjunction with tools using file watching to trigger package resolution which is something that e.g. the Swift VS Code plugin does. We can resolve this by locking the .build directory for the duration of execution of any `SwiftTool` such that any following access will do a blocking wait until unlock. This is using the same infrastructure that we are already using for the shared repository cache. Unlike the shared cache, tool execution can take a long time, so we'll inform the user about the waiting process so that they can decide to cancel instead. rdar://113964179
I wonder if we need/want to do anything special for non-interactive execution (e.g. always bail if |
swiftlang/swift-tools-support-core#458 |
Not sure I understand the Linux failure:
|
Oh, of course this is because self-hosted jobs don't support cross repo testing. |
swiftlang/swift-tools-support-core#458 |
Windows failure looks related:
|
swiftlang/swift-tools-support-core#458 |
nice! I proposed to lock a few years ago #2036 (comment), which, unfortunately, was rejected as not needed. I'm happy to see the idea finally made it through. @neonichu The work is here in case that may be helpful in terms of scope #2037. One thing is that I believe Workspace should do the locking too, like when invoked by the sourcekit-lsp or other such. |
We're seeing hangs in self-hosted jobs since merging this and I can't repro locally, so let's try this speculative revert to see whether it resolves the issues. Reverts #7269
To answer myself here somewhat delayed, it doesn't seem as if we can do anything for non-interactive execution without requiring changes to the VS Code plugin (and potentially many other integrations that are shelling out to SwiftPM). By definition these integrations are non-interactive and if we don't make them wait they would fail in potentially many scenarios that work fine today. |
what exactly? shouldn't sourcekit-lsp at least be aware and avoid command line execution overlap? |
The VS Code plugin shells out directly to |
that's exactly my point. these two may (and do) overlap without any lock |
Currently, concurrent execution of SwiftPM can easily break the state in .build irreparably. This is especially in conjunction with tools using file watching to trigger package resolution which is something that e.g. the Swift VS Code plugin does.
We can resolve this by locking the .build directory for the duration of execution of any
SwiftTool
such that any following access will do a blocking wait until unlock. This is using the same infrastructure that we are already using for the shared repository cache. Unlike the shared cache, tool execution can take a long time, so we'll inform the user about the waiting process so that they can decide to cancel instead.rdar://113964179