Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Celery hangs when an exception occurs inside a group of chains with redis as a broker #6437

Open
11 of 18 tasks
emanuelmd opened this issue Oct 25, 2020 · 1 comment
Open
11 of 18 tasks

Comments

@emanuelmd
Copy link

emanuelmd commented Oct 25, 2020

Checklist

  • This has already been asked to the discussion group first.
  • I have read the relevant section in the
    contribution guide
    on reporting bugs.
  • I have checked the issues list
    for similar or identical bug reports.
  • I have checked the pull requests list
    for existing proposed fixes.
  • I have checked the commit log
    to find out if the bug was already fixed in the master branch.
  • I have verified that the issue exists against the master branch of Celery.
  • I have included all related issues and possible duplicate issues
    in this issue (If there are none, check this box anyway).

Mandatory Debugging Information

  • I have included the output of celery -A proj report in the issue.
    (if you are not able to do this, then at least specify the Celery
    version affected).
  • I have verified that the issue exists against the master branch of Celery.
  • I have included the contents of pip freeze in the issue.
  • I have included all the versions of all the external dependencies required
    to reproduce this bug.

Optional Debugging Information

  • I have tried reproducing the issue on more than one Python version
    and/or implementation.
  • I have tried reproducing the issue on more than one message broker and/or
    result backend.
  • I have tried reproducing the issue on more than one version of the message
    broker and/or result backend.
  • I have tried reproducing the issue on more than one operating system.
  • I have tried reproducing the issue on more than one workers pool.
  • I have tried reproducing the issue with autoscaling, retries,
    ETA/Countdown & rate limits disabled.
  • I have tried reproducing the issue after downgrading
    and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

  • N/A

Related Issues

  • None

Possible Duplicates

  • I've skimmed the issues list and the internet and it seems there's definitely something going on with this kind of chain composition. It seems the issue has been dating since at least 2013 and I can reproduce it on Celery 5.0.1 & 4.7.x

Environment & Settings

  • Celery 5.0.1 & 4.7.x
  • I included the report in the demo repo

Steps to Reproduce

  • Follow the instructions inside the demo repo

Required Dependencies

  • Minimal Python Version: Tested with 3.7.0, 3.8.0 & 3.8.5
  • Minimal Celery Version: 4.7.x

Python Packages

  • Included in demo repo

Other Dependencies

  • N/a

Minimally Reproducible Test Case

https://github.com/emanuelmd/freezelery

Expected Behavior

  • Exceptions should be propagated from chains that contain groups

Actual Behavior

  • The calling code hangs

Notes

Happy to help tracking this down. Let me know if you need any other information

@maybe-sybr
Copy link
Contributor

This appears to be related to chords misbehaving again - possibly an edge case we missed in #6354 or something nearby? I have a more MRTC here which appears to cover the gist of your linked repository:

import atexit

import celery

app = celery.Celery("app", broker="redis://", backend="redis://")

@app.task
def nop(*_):
    pass

@app.task
def die(*_):
    raise RuntimeError

g = celery.group((nop.s() | die.s() | celery.group(nop.s())) for _ in range(3))
r = g.delay()

atexit.register(lambda: print(r.get(disable_sync_subtasks=False, timeout=1)))

You can run celery -A app worker -l DEBUG and then ^C out after the three runtime errors appear. The atexit sync get will timeout if the final element of each chain in a group (ie. exception in chord header which is magically constructed from the group with a preceding chain element).

Removing the external group so it's just a single chain allows the result object to be joined without timing out, so my gut feel is that perhaps a task ID or some completion event for the encapsulating group isn't being handled properly. Maybe the promoted chord doesn't retain some task ID which is needed to finalise the chain for an encapsulating canvas signature type?

thedrow added a commit that referenced this issue Mar 17, 2021
thedrow added a commit that referenced this issue Mar 17, 2021
auvipy pushed a commit that referenced this issue Mar 22, 2021
* Added testcase for issue #6437.

* Add second test case.
jeyrce pushed a commit to jeyrce/celery that referenced this issue Aug 25, 2021
* Added testcase for issue celery#6437.

* Add second test case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants