Repository navigation
Chain-in-chord that fails before the last task in the chain now triggers chord error handling - #6226
msci-jordancrawford wants to merge 2 commits into
Conversation
Marked with xfail for now.
|
This pull request introduces 2 alerts and fixes 5 when merging 04226b1 into d537be4 - view on LGTM.com new alerts:
fixed alerts:
|
This seems like it's almost certainly not the right way to fix this problem, though it does cause the tests to turn green...
|
I went ahead and added a fix as well, which should at least cause the tests to pass. That said, it really doesn't seem like the correct fix - if any of the maintainers have a suggestion for a more elegant way to fix this, it would be much appreciated. Thanks ahead of time! I'm also not sure what the 'correct' behavior here is - should the client be expecting a |
|
This pull request introduces 1 alert and fixes 4 when merging 13c2e06 into d537be4 - view on LGTM.com new alerts:
fixed alerts:
|
| if request: | ||
| if request.chord: | ||
| self.on_chord_part_return(request, state, exc) | ||
| elif request.chain and 'chord' in request.chain[-1]['options']: |
There was a problem hiding this comment.
does this solve the reported issue?
There was a problem hiding this comment.
Yes. The problem is that this snippet of code is executed for the task in the chain that fails, but only the final task in the chain passes the if request.chord check, so the chord only gets notified if it's the final task in the chain that fails. Adding this check solves the problem as bluntly as possible: by simply checking for a chord associated with the last element in the chain and updating it if necessary. Very much unsure if that is the right way forward.
It looks like it also breaks a couple of other tests. I think fixing those tests would just be a matter of changing this line to:
elif getattr(request, 'chain', None) and 'chord' in request.chain[-1]['options']:but that just further reinforces my idea that this is maybe not the right way/place to be fixing this problem.
| assert len([cr for cr in chord_results if cr[2] != states.SUCCESS] | ||
| ) == 1 | ||
|
|
||
| def test_chain_in_chord_on_error(self, manager): |
There was a problem hiding this comment.
the integration test has changed upstream, can you rebase, please?
|
@matusvalo Please rebase this. If you have the time, please debug this further. |
|
I don't know whether this is best reported here or on the issue, but this seems to be where the bulk of the discussion is. I hope the following is useful: I've rebased this PR on top of the v4.4.7 tagged commit here: v4.4.7...maxfenv:chord_in_chain_error_propogation In the context of one of the projects we maintain that uses celery, I wrote some unit tests that highlight the issue in that context and that fail with celery 4.4.7 but pass with this pr applied. I also applied the change suggested by @msci-jordancrawford ( For anyone wanting to replicate that exactly, it is also necessary to pin the dependencies in I hope to do a large scale integration test of this fix tomorrow and should be able to report on it's outcome by the day after that. Thank you very much @msci-jordancrawford for your work in hunting down, documenting and fixing this issue. This has been causing us grief for some time! |
|
Could you please contribute the unit tests? |
|
Yes I can do, though they are fundamentally not different to the test already included here. I could commit them to my fork or include them as a snipped here, I of course can't push directly to the source branch of this PR. |
|
If they are not different, then why did you write them? |
|
I wrote them because the barrier to entry was lower than figuring out how to run the celery project's unit tests from cold. I've since done that anyway, but it seemed like the thing to do at the time. Again, I wrote those tests in another project. In any case, I've added a those hopefully non controversial test cases to I'm unsure about decorating them with |
|
Unfortunately error handling appears to not work if the failing task is not in the last two tasks of a chain. That is to say: The chord error fires correctly if the failing task in the chain is either the last or second to last, but not if it is (say) the 1st or 2nd out of 4. Here are some more tests to highlight that issue: 1a3b36b We shall have a think about what the fix might look like and report back. Since this is starting to diverge substantially from the commits in this PR at this point, would it be acceptable to open a new PR with the fix (if one is forthcoming). I will still base the branch off of this one, so @msci-jordancrawford's commits remain in the history. I don't want to claim any undue credit here. |
|
The issue appears to be that the context with the 'chord' key in the 'options' is always the first element of the However, I'm not certain on that point, so instead I opted to check for all contexts with a 'chord' and to pick the first among those, if any. I've commited those changes to my version of this branch: https://github.com/maxfenv/celery/tree/chord_in_chain_error_propogation. The code there passes all tests, apart from |
|
The test failure mention above only occurs on python < 3.8 and is, I believe, related to mismatching versions of pickle. Something like this: https://stackoverflow.com/questions/63329657/python-3-7-error-unsupported-pickle-protocol-5 |
|
Oh my gosh, yes! Thank you for the changeset @msci-jordancrawford and thanks for bumping this @maxfenv . I was smashing my face against this all of yesterday without having seen this. My gut feel is that this approach will work but I was a bit concerned about reaching deep into the |
|
There is a PR up (#6746) which should fix this issue. I'm going to close this PR in favour of that one. |
Marked with xfail for now.
Note: Before submitting this pull request, please review our contributing
guidelines.
Description
Fixes #6220.