release lock on global process-compose before attaching #2645
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
After running
devbox services attach
all otherdevbox services ...
commands hang until the attached UI is exited. This is because there's a lock put on the global process-compose file while it's being read and it's not released until the program exits.You can see in
devbox services up
the lockfile is released, looks like it was just missed in attach.devbox/internal/services/manager.go
Lines 188 to 189 in dd069a4
How was it tested? (repro steps, hangs without this PR, works as expected with it)
In one terminal, in a devbox repo with process(es)
In another terminal, in the same dir or any other devbox repo>
Other note
The
lock()
function has a timeout and error handling, why doesn't it work?devbox/internal/services/manager.go
Lines 374 to 394 in dd069a4
The line that hangs is 391, when we're trying to close the file after the timeout, the file can't be closed because another process has it open and/or locked. I did investigate adding a timeout
file.Close()
but could not get it to work reliably for myself.Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.