The Fix
pip install celery==5.4.0
Based on closed celery/celery issue #8890 · PR/commit linked
Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.
@@ -1225,6 +1225,12 @@ def prepare_steps(self, args, kwargs, tasks,
root_id=root_id, app=app,
)
+ if tasks:
+ prev_task = tasks[-1]
+ prev_res = results[-1]
import celery
celery_app = celery.Celery()
celery_app.config_from_object({
'broker_url': 'memory://',
'broker_backend': 'memory://',
'result_backend': 'cache+memory://'
})
@celery.shared_task
def test_task(x: int):
print(x)
def main():
t1 = celery.chain(test_task.s(0), celery.group(test_task.s(1), test_task.s(2)), test_task.s(3) | test_task.s(4))
t2 = celery.chord([test_task.s(5), test_task.s(6)], t1)
t3 = celery.chord([test_task.s(7)], t2)
t3.apply_async()
if __name__ == '__main__':
main()
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install celery==5.4.0\nWhen NOT to use: Do not apply this fix if the task structure does not include groups in the middle.\n\n
Why This Fix Works in Production
- Trigger: t3.apply_async()
- Mechanism: The issue arises from incorrect handling of task chains that include a group in the middle
- Why the fix works: Fixes a bug related to recursive result parents in task chains that include a group in the middle. (first fixed release: 5.4.0).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- The issue arises from incorrect handling of task chains that include a group in the middle
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #8890
- Fix PR: https://github.com/celery/celery/pull/8903
- First fixed release: 5.4.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.43
Verified Execution
We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.
- Status: PASS
- Ran: 2026-02-11T16:52:29Z
- Package: celery
- Fixed: 5.4.0
- Mode: fixed_only
- Outcome: ok
Logs
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“# Checklist <!-- To check an item on the list replace [ ] with [x]. --> - [x] I have verified that the issue exists against the main branch of Celery. - [ ] This has already been asked to the discussions forum first. - [x] I have read the r”
Failure Signature (Search String)
- t3.apply_async()
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "scratch.py", line 20, in <module>
t3.apply_async()
File "C:\git\celery\celery\canvas.py", line 2152, in apply_async
return self.run(tasks, body, args, task_id=task_id, kwargs=kwargs, **merged_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\git\celery\celery\canvas.py", line 2233, in run
bodyres = body.freeze(task_id, root_id=root_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\git\celery\celery\canvas.py", line 2093, in freeze
raise RuntimeError('Recursive result parents')
RuntimeError: Recursive result parents
Minimal Reproduction
import celery
celery_app = celery.Celery()
celery_app.config_from_object({
'broker_url': 'memory://',
'broker_backend': 'memory://',
'result_backend': 'cache+memory://'
})
@celery.shared_task
def test_task(x: int):
print(x)
def main():
t1 = celery.chain(test_task.s(0), celery.group(test_task.s(1), test_task.s(2)), test_task.s(3) | test_task.s(4))
t2 = celery.chord([test_task.s(5), test_task.s(6)], t1)
t3 = celery.chord([test_task.s(7)], t2)
t3.apply_async()
if __name__ == '__main__':
main()
What Broke
Tasks may fail to execute properly, leading to unexpected behavior in task chains.
Why It Broke
The issue arises from incorrect handling of task chains that include a group in the middle
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install celery==5.4.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/celery/celery/pull/8903
First fixed release: 5.4.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if the task structure does not include groups in the middle.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 5.4.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.