Skip to content

Refactor BuildWithResultHandler to simplify concurrency usage#1504

Merged
tonistiigi merged 3 commits into
docker:masterfrom
jedevc:fix-1497
Jan 25, 2023
Merged

Refactor BuildWithResultHandler to simplify concurrency usage#1504
tonistiigi merged 3 commits into
docker:masterfrom
jedevc:fix-1497

Conversation

@jedevc
Copy link
Copy Markdown
Collaborator

@jedevc jedevc commented Jan 10, 2023

🛠️ Fixes #1497.

Using the error group concurrency primitive we can avoid needing to create a separate wait group.

This allows us to sidestep the issue described in #1497 (comment) where the wait group could be completed, but the build invocation functions had not terminated - if one of the functions was to terminate with an error, then it was possible to encounter a race condition, where the result handling code would begin executing, despite an error.

The refactor to use a separate error group which more elegantly handles the concept of function returns and errors, ensures that we can't encounter this issue.

For clarity, this fix is split in to three separate commits, the first two refactoring to simplify the fix, the final one the actual fix, to make the diffs easier to review.

Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Using the syncronization primitive, we can avoid needing to create a
separate wait group.

This allows us to sidestep the issue where the wait group could be
completed, but the build invocation functions had not terminated - if
one of the functions was to terminate with an error, then it was
possible to encounter a race condition, where the result handling code
would begin executing, despite an error.

The refactor to use a separate error group which more elegantly handles
the concept of function returns and errors, ensures that we can't
encounter this issue.

Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc jedevc added the kind/bug Something isn't working label Jan 10, 2023
@tonistiigi tonistiigi added this to the v0.10.1 milestone Jan 17, 2023
Copy link
Copy Markdown
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks bit scary (for cherry-pick), but I can't find any reason why it shouldn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: runtime error: invalid memory address or nil pointer dereference in BuildWithResultHandler

3 participants