Serialize concurrent builder ensures with a file lock - #2174
Closed
MayCXC wants to merge 1 commit into
Closed
Conversation
Simultaneous build invocations that find no builder race one another through create, bootstrap, and the failure cleanup: the create loser proceeds against the winner's container, collides with its bootstrap, and the cleanup deletes the container the winner just started, so a cold system under parallel builds may never converge on a running builder. An advisory flock around the ensure section admits one invocation at a time; whichever enters first creates or repairs the builder and the rest observe the finished state. buildx serializes its builder store the same way. https://github.com/docker/buildx/blob/master/store/store.go
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type of Change
Motivation and Context
Closes #2167.
Simultaneous build invocations that find no builder race one another through create, bootstrap, and the failure cleanup: the create loser proceeds against the winner's container, collides with its bootstrap, and the cleanup deletes the container the winner just started, so a cold system under parallel builds may never converge on a running builder.
An advisory
flockaround the ensure section admits one invocation at a time; whichever enters first creates or repairs the builder and the rest observe the finished state. buildx serializes its builder store the same way: https://github.com/docker/buildx/blob/master/store/store.goThis may be the root cause behind #1072 (dialing a builder hangs with no feedback) and #1159 (builder container gets stuck and cannot be deleted), both of which describe what this race produces.
Testing
Parallel
container buildinvocations from a cold system converge on one running builder instead of deleting each other's.Integration suite: 397 passed. Unit suite: 772 passed.
make fmt,make checkclean.