Repository navigation
Closed
Description
Checklist
- I have verified that the issue exists against the
masterbranch of Celery. - 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 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 reportin 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
masterbranch of Celery. - I have included the contents of
pip freezein 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
Related Issues
- None
Possible Duplicates
- None
Environment & Settings
Celery version: 5.1.0b1 (singularity)
celery report Output:
software -> celery:5.1.0b1 (singularity) kombu:5.1.0b1 py:3.8.5
billiard:3.6.4.0 py-amqp:5.0.6
platform -> system:Linux arch:64bit, ELF
kernel version:5.8.0-48-generic imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:redis://localhost/
broker_url: 'amqp://guest:********@localhost:5672//'
result_backend: 'redis://localhost/'
deprecated_settings: None
Steps to Reproduce
Required Dependencies
- Minimal Python Version: N/A or Unknown
- Minimal Celery Version: N/A or Unknown
- Minimal Kombu Version: N/A or Unknown
- Minimal Broker Version: N/A or Unknown
- Minimal Result Backend Version: N/A or Unknown
- Minimal OS and/or Kernel Version: N/A or Unknown
- Minimal Broker Client Version: N/A or Unknown
- Minimal Result Backend Client Version: N/A or Unknown
Python Packages
pip freeze Output:
Other Dependencies
Details
N/A
Minimally Reproducible Test Case
Details
import celery
app = celery.Celery(
broker='amqp://localhost',
backend='redis://localhost',
)
@app.task
def task_a(number):
print(f'Task A: {number}')
return number
@app.task
def task_b(number):
print(f'Task B: {number}')
return number
@app.task
def task_c(number):
print(f'Task C: {number}')
if __name__ == '__main__':
celery.chord(
(celery.chain(task_a.s(i), task_b.s()))
for i in range(3)
)(task_c.s()) # yapf: disable
app.start()Expected Behavior
Expected output:
[2021-04-11 16:44:51,364: WARNING/ForkPoolWorker-15] Task A: 0
[2021-04-11 16:44:51,364: WARNING/ForkPoolWorker-16] Task A: 1
[2021-04-11 16:44:51,364: WARNING/ForkPoolWorker-1] Task A: 2
[2021-04-11 16:44:51,387: WARNING/ForkPoolWorker-4] Task B: 2
[2021-04-11 16:44:51,387: WARNING/ForkPoolWorker-3] Task B: 0
[2021-04-11 16:44:51,387: WARNING/ForkPoolWorker-2] Task B: 1
[2021-04-11 16:44:51,413: WARNING/ForkPoolWorker-15] Task C: [0, 1, 2]
On celery==5.0.5 it works fine
Actual Behavior
[2021-04-11 16:33:24,583: WARNING/ForkPoolWorker-15] Task A: 0
[2021-04-11 16:33:24,583: WARNING/ForkPoolWorker-1] Task A: 2
[2021-04-11 16:33:24,583: WARNING/ForkPoolWorker-16] Task A: 1
[2021-04-11 16:33:24,608: WARNING/ForkPoolWorker-4] Task B: 2
[2021-04-11 16:33:24,608: WARNING/ForkPoolWorker-2] Task B: 0
[2021-04-11 16:33:24,608: WARNING/ForkPoolWorker-3] Task B: 1
Activity
open-collective-bot commentedon Apr 11, 2021
Hey @Sobes76rus 👋,
Thank you for opening an issue. We will get back to you as soon as we can.
Also, check out our Open Collective and consider backing us - every little helps!
We also offer priority support for our sponsors.
If you require immediate assistance please consider sponsoring us.
thedrow commentedon Apr 12, 2021
@maybe-sybr If you can't get to it, I will.
I marked it as a blocker for 5.1.0 so we have to do it.
maybe-sybr commentedon Apr 12, 2021
Looks like a bug in chord size counting again. For some reason we've counted 8 chord parts to return which is way off what it should be:
maybe-sybr commentedon Apr 13, 2021
Counting of chord size children of groups is busted.
celery/celery/canvas.py
Lines 1178 to 1185 in 1901ea8
The else case here is counting the length of a simple signature which is the length of its top level attributes (args, kwargs, and friends). Running the MRTC with the following diff on celery master:
->
It looks like the else case on L1183 is assuming that the trailing task of the signature being checked (which is a chain since we passed the condition on L1180) is also a chain. In the MRTC the trailing task is a simple signature!
Couple of takeaways:
subtask_typeis highly suspicious first of all. We should probably be doing an isinstance check since I think the objects we're touch at this stage are well formedSignatureinstances (otherwise.subtask_typewould blow up).I'll try to find some time to get a patch up this evening. We'll also want to add a couple of regression tests. This should affect all backends with chords since it's a counting error so unit tests and a chord supporting backend integration test would be nice.
Edit: FTR the broken lines were added in #6576 but IDK if it functioned as expected before then
maybe-sybr commentedon Apr 13, 2021
This diff does appear to run the MRTC as expected ->
The logic is this block is actually a little more tortured than I thought. It's re-writing the chord size each time it loops but I think it needs to do this in an additive way which it doesn't appear to be doing, as well as possibly handling tail groups and chords but not chains. We'll have to think about this pretty carefully, like usual with these chord counting issues :/
thedrow commentedon Apr 13, 2021
Thank you for the analysis, @maybe-sybr. ❤️
Would you be able to come up with a fix?
maybe-sybr commentedon Apr 14, 2021
I should have time to sit down and work through this is in the next day or two, yeah. I've actually found another edge case which might be related to this code and is affecting my own work so I'll be able to spend some time digging into it and hopefully get a PR up before this weekend.
maybe-sybr commentedon Apr 18, 2021
This is on my list for today.