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

A task will run multiple times when chaining chains with groups #9020

Open
7 of 19 tasks
DorSSS opened this issue May 13, 2024 · 0 comments · May be fixed by #9021
Open
7 of 19 tasks

A task will run multiple times when chaining chains with groups #9020

DorSSS opened this issue May 13, 2024 · 0 comments · May be fixed by #9021

Comments

@DorSSS
Copy link

DorSSS commented May 13, 2024

Checklist

  • I have verified that the issue exists against the main branch of Celery.
  • This has already been asked to the discussions forum 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 main branch.
  • I have included all related issues and possible duplicate issues
    in this issue (If there are none, check this box anyway).
  • I have tried to reproduce the issue with pytest-celery and added the reproduction script below.

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 main 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

Related Issues

  • None

Possible Duplicates

  • None

Environment & Settings

Celery version:

celery report Output:

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

N/A

Minimally Reproducible Test Case

Expected Behavior

Actual Behavior

Happens on the latest version of celery.

On some complex scenarios, when there is some chaining of chains that contain groups, a task that is chained after a group will run multiple times.
For example, here task_b and task_c should be printed only once, but each one is printed twice

app = Celery('tasks', broker='memory://', result_backend='cache+memory://')


@app.task(bind=True)
def task_a(self):
    print("task_a")


@app.task(bind=True)
def task_b(self):
    print('task_b')


@app.task(bind=True)
def task_c(self):
    print("task_c")


group1 = celery.group(task_a.si(), task_a.si())
group2 = celery.group(task_a.si(), task_a.si())
chord1 = group1 | group2
chord2 = celery.chain(chord1, (task_b.si() | task_c.si())).apply_async()

Output:

[2024-05-13 10:12:37,405: INFO/MainProcess] Task celery.task_a[d947d22f-900a-454e-a3cd-dee12dedfb4a] succeeded in 0.5s: None
[2024-05-13 10:12:37,405: INFO/MainProcess] Task celery.task_a[4dc6c550-70fb-46d6-8967-1c92783682b4] received
[2024-05-13 10:12:37,405: WARNING/MainProcess] task_a
[2024-05-13 10:12:37,407: INFO/MainProcess] Task celery.task_a[4dc6c550-70fb-46d6-8967-1c92783682b4] succeeded in 0.0s: None
[2024-05-13 10:12:37,407: INFO/MainProcess] Task celery.task_a[eb8dc8d9-30e6-4b30-aa4f-b867d85b817c] received
[2024-05-13 10:12:37,408: WARNING/MainProcess] task_a
[2024-05-13 10:12:37,408: INFO/MainProcess] Task celery.task_a[eb8dc8d9-30e6-4b30-aa4f-b867d85b817c] succeeded in 0.0s: None
[2024-05-13 10:12:37,409: INFO/MainProcess] Task celery.task_b[88f28e3b-a986-4f20-9ce0-b4a28b0c669b] received
[2024-05-13 10:12:37,409: WARNING/MainProcess] task_b
[2024-05-13 10:12:37,410: INFO/MainProcess] Task celery.task_b[88f28e3b-a986-4f20-9ce0-b4a28b0c669b] succeeded in 0.0s: None
[2024-05-13 10:12:37,410: INFO/MainProcess] Task celery.task_b[88f28e3b-a986-4f20-9ce0-b4a28b0c669b] received
[2024-05-13 10:12:37,410: WARNING/MainProcess] task_b
[2024-05-13 10:12:37,411: INFO/MainProcess] Task celery.task_b[88f28e3b-a986-4f20-9ce0-b4a28b0c669b] succeeded in 0.0s: None
[2024-05-13 10:12:37,411: INFO/MainProcess] Task celery.task_c[8bb0b7fc-c3f8-4fea-a2c9-13e8f9ae7dbd] received
[2024-05-13 10:12:37,411: WARNING/MainProcess] task_c
[2024-05-13 10:12:37,412: INFO/MainProcess] Task celery.task_c[8bb0b7fc-c3f8-4fea-a2c9-13e8f9ae7dbd] succeeded in 0.0s: None
[2024-05-13 10:12:37,412: INFO/MainProcess] Task celery.task_c[8bb0b7fc-c3f8-4fea-a2c9-13e8f9ae7dbd] received
[2024-05-13 10:12:37,412: WARNING/MainProcess] task_c
[2024-05-13 10:12:37,412: INFO/MainProcess] Task celery.task_c[8bb0b7fc-c3f8-4fea-a2c9-13e8f9ae7dbd] succeeded in 0.0s: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant