Skip to content

fix: Error propagation and errback calling for group-like signatures - #6746

Merged
auvipy merged 6 commits into
masterfrom
fix/chord-child-error-propagation
May 8, 2021
Merged

auvipy merged 6 commits into
masterfrom
fix/chord-child-error-propagation

Conversation

@maybe-sybr

Copy link
Copy Markdown
Contributor

Description

Fix propagation of errors and errback calling from chord and group children. This changeset
supersedes #6226 and rolls in some of the test cases presented by @maxfenv in comments
on that PR.

Fixes #6220 and a few other issues discovered along the way.

@maybe-sybr

maybe-sybr commented Apr 27, 2021 •

Copy link
Copy Markdown
Contributor Author

This PR is blocked by #6733 since it tests some behaviours affected by that bug and the branch up for merge here contains a merge of that one to get the tests green.

@maybe-sybr

Copy link
Copy Markdown
Contributor Author

Unit test failures noted, they're due to dumb mocking somewhere unrelated. I'll sort that out this afternoon.

@maybe-sybr

Copy link
Copy Markdown
Contributor Author

@maxfenv and @msci-jordancrawford - if you have time, could you please look over the changes here and let me know if I've butchered anything improperly or if you have any other concerns with the changeset? Any input would be welcomed :)

@lgtm-com

lgtm-com Bot commented Apr 27, 2021

Copy link
Copy Markdown

This pull request introduces 2 alerts and fixes 1 when merging 63d5ae6 into 230c9ac - view on LGTM.com

new alerts:

  • 1 for Unnecessary 'else' clause in loop
  • 1 for Module is imported with 'import' and 'import from'

fixed alerts:

  • 1 for Unused import

@maybe-sybr
maybe-sybr force-pushed the fix/chord-child-error-propagation branch from 63d5ae6 to da28da9 Compare April 27, 2021 03:09
@codecov

codecov Bot commented Apr 27, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #6746 (2f3faf9) into master (426a8f9) will decrease coverage by 0.05%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6746      +/-   ##
==========================================
- Coverage   70.66%   70.61%   -0.06%     
==========================================
  Files         138      138              
  Lines       16566    16585      +19     
  Branches     2082     2086       +4     
==========================================
+ Hits        11706    11711       +5     
- Misses       4665     4678      +13     
- Partials      195      196       +1     
Flag Coverage Δ
unittests 70.61% <33.33%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
celery/backends/base.py 92.67% <26.31%> (-2.22%) ⬇️
celery/canvas.py 94.82% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 426a8f9...2f3faf9. Read the comment docs.

@lgtm-com

lgtm-com Bot commented Apr 27, 2021

Copy link
Copy Markdown

This pull request introduces 1 alert and fixes 1 when merging da28da9 into 230c9ac - view on LGTM.com

new alerts:

  • 1 for Unnecessary 'else' clause in loop

fixed alerts:

  • 1 for Non-exception in 'except' clause

@maybe-sybr

maybe-sybr commented Apr 27, 2021 •

Copy link
Copy Markdown
Contributor Author

Patch coverage seems a bit suspicious, I think the lines it backend/base.py it's flagging as not covered should be getting hit.

Edit: Oh, perhaps coverage is only being measured for the unit tests? The new lines are only hit by integration tests I think

Comment thread celery/canvas.py Resolved
@auvipy

auvipy commented Apr 27, 2021

Copy link
Copy Markdown
Member

massive!

Comment thread celery/canvas.py Resolved
from time import sleep

import pytest
import pytest_subtests # noqa: F401

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

Suggested change
import pytest_subtests # noqa: F401

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is for the side-effect which allows us to use the subtests fixture. I could do something like

import pytests_subtests as _side_effect  # noqa: F401

to make that more obvious perhaps. I just ^c^ved this from the other test suite where we use subtests.

@thedrow thedrow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great.
Could you please run isort on this patch?

maybe-sybr added 4 commits May 7, 2021 11:00
Giving a linked task callback to the 0th task in a group is fine, but
for errbacks it's not an appropriate choice since any task in the group
could fail. This ensures that if any task other than the 0th one fails,
the errback will be called. This opens the possibility for an errback to
be called more than once when linked to a group, but generally we expect
that they should be design to be idempotent so no warning is issued for
the changed behaviour.
These tests simply encode the currently expected behaviour where
errbacks linked to a group will be called once for each failed task, as
well as the consequences for chords which turn their header into a group
if it is not one already.
@maybe-sybr
maybe-sybr force-pushed the fix/chord-child-error-propagation branch from da28da9 to 2f3faf9 Compare May 7, 2021 01:01
@maybe-sybr

maybe-sybr commented May 7, 2021 •

Copy link
Copy Markdown
Contributor Author

@thedrow - rebased and this should be okay to merge unless you have any reason to not resolve the two outstanding threads. I've added a bit of documentation to cover what @maxfenv and I spoke about above, basically pointing out that group call/errbacks are a bit odd since groups don't really exist and chords implement better behaviour.

I'll check back on CI here shortly to avoid blocking on that being red.

Do we need to land this in a b3 or shall we just aim for rc1?

Edit: Coverage is complaining about stuff which is only covered under the integration tests so I think it's okay. I've been running the tests against a redis broker/backend here and they seem quite happy.

@lgtm-com

lgtm-com Bot commented May 7, 2021

Copy link
Copy Markdown

This pull request fixes 1 alert when merging 2f3faf9 into 426a8f9 - view on LGTM.com

fixed alerts:

  • 1 for Unused import

@maybe-sybr

Copy link
Copy Markdown
Contributor Author

@thedrow low priority ping on this. It should be good for you to land if you're comfortable with it appearing in the RC1. Otherwise we can merge after 5.1 is pushed out.

@auvipy
auvipy merged commit 6dd3852 into master May 8, 2021
@auvipy

auvipy commented May 8, 2021

Copy link
Copy Markdown
Member

merging this as the actual fix is not that big and it's a bug fix. so it should be qualified for 5.1.0rc

@thedrow

thedrow commented May 9, 2021

Copy link
Copy Markdown
Contributor

merging this as the actual fix is not that big and it's a bug fix. so it should be qualified for 5.1.0rc

Good call.

@auvipy
auvipy deleted the fix/chord-child-error-propagation branch May 9, 2021 07:56
jeyrce pushed a commit to jeyrce/celery that referenced this pull request Aug 25, 2021
…elery#6746)

* fix: Use chord kwarg over request in group.apply

* fix: Propagate errors from failed chain tasks

Fixes celery#6220

Co-authored-by: Maximilian Friedersdorff <[email protected]>
Co-authored-by: maybe-sybr <[email protected]>

* fix: Ensure all subtasks of a group get errbacks

Giving a linked task callback to the 0th task in a group is fine, but
for errbacks it's not an appropriate choice since any task in the group
could fail. This ensures that if any task other than the 0th one fails,
the errback will be called. This opens the possibility for an errback to
be called more than once when linked to a group, but generally we expect
that they should be design to be idempotent so no warning is issued for
the changed behaviour.

* test: Add tests for child error propagation

* test: Add regression tests for group errback dupes

These tests simply encode the currently expected behaviour where
errbacks linked to a group will be called once for each failed task, as
well as the consequences for chords which turn their header into a group
if it is not one already.

* doc: Add extra docs for canvas call/errback usage

Co-authored-by: Crawford, Jordan <[email protected]>
Co-authored-by: Maximilian Friedersdorff <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chain-in-chord that fails before the last task in the chain doesn't trigger chord error handling

5 participants