Repository navigation
Description
A chord stays PENDING forever, with no error or errback, when the pool process running any header is killed after that header stored SUCCESS and before its part return ended. Main (768e476), Redis backend, prefork. Memcached, DynamoDB and GCS count parts in the worker too (untested). The database backend uses chord_unlock and isn't affected (0 of 3).
| Redis broker and backend | PENDING |
|---|---|
| Random child SIGKILLed about every 2 s, 50 headers of 20 KB | 5 of 600, 10 of 600 |
| OOM kill in a 400 MiB container, 40 headers of 2 MB | 5 of 5 (2 GiB: 0 of 8) |
| Child SIGKILLed after its SUCCESS write | 10 of 10 (last header), 5 of 5 (first) |
| Child SIGKILLed while the header ran | 0 of 10, 0 of 20 |
Worker restarts, 7x the claim TTL, result_chord_join_timeout, task_reject_on_worker_lost on or off, early ack and worker_deduplicate_successful_tasks don't help.
Checklist
- I have verified that the issue exists against the
mainbranch 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 reportin the issue. - I have verified that the issue exists against the
mainbranch 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
- A task whose SUCCESS is stored still fires its error callback: a pool child lost after the store, or a raising on_success #10724, Don't fail a task whose SUCCESS was stored before the worker was lost #10752 (ack without part return), Redis backend: a chord header that runs twice makes the body run early with the wrong input #10910, Count each chord header task only once in the Redis backend #10919.
- Redis backend: chord body can be dispatched twice when a duplicate header task finishes during callback dispatch #10997, Fix#10997 - redis chord claim cleanup ownership #10998: a whole worker lost after the claim is an accepted trade-off there; the Redis broker is safe only while the claim TTL is below
visibility_timeout.
Possible Duplicates
- None
Environment & Settings
Celery version: 5.7.0 (768e476)
celery report Output:
software -> celery:5.7.0 (collider) kombu:5.7.0 py:3.14.6
billiard:4.3.2 redis:8.1.0
settings -> transport:redis results:redis://localhost:6379/1
broker_url: 'redis://:********@localhost:6379/0'
result_backend: 'redis://localhost:6379/1'
task_acks_late: True
task_reject_on_worker_lost: True
worker_prefetch_multiplier: 1
Steps to Reproduce
Required Dependencies
Minimal versions
- Minimal Celery Version: 5.7.0
- Minimal Broker Version: Redis 7.4
- Minimal Result Backend Version: Redis 7.4
- Python, kombu, OS and clients: N/A or Unknown
Python Packages
pip freeze Output:
billiard==4.3.2
celery @ main (768e476)
kombu==5.7.0
redis==8.1.0
Other Dependencies
Services
Redis 7.4.
Minimally Reproducible Test Case
tasks.py, run.py, random child kills and output
# tasks.py
import time
from celery import Celery
app = Celery("tasks", broker="redis://localhost:6379/0", backend="redis://localhost:6379/1")
app.conf.task_acks_late = True
app.conf.task_reject_on_worker_lost = True
app.conf.worker_prefetch_multiplier = 1
@app.task
def part(i):
time.sleep(0.05)
return "x" * 20_000
@app.task
def total(results):
return len(results)# run.py
import time
from collections import Counter
from celery import chord
from tasks import app, part, total
bodies = []
for i in range(300):
bodies.append(chord(part.s(j) for j in range(50))(total.s()))
if i >= 2:
try:
bodies[i - 2].get(timeout=30, propagate=False)
except Exception:
pass
time.sleep(30)
print(Counter(app.AsyncResult(b.id).state for b in bodies))$ celery -A tasks worker -P prefork -c 4 -l warning & W=$!
$ while kill -0 $W; do sleep $(awk 'BEGIN{srand(); print -2*log(1-rand())}'); kill -9 $(pgrep -P $W | shuf -n 1); done &
$ python run.py
Counter({'SUCCESS': 294, 'PENDING': 6})PENDING chords: 50 SUCCESS headers, 49 or 50 entries in <group>.j.
Expected Behavior
The body runs, or the chord fails with a ChordError and the errback runs.
Actual Behavior
The child stores SUCCESS, then runs the part return (celery/backends/base.py:294). If it's killed:
- Before the part is counted (
.jone short), the main process sees SUCCESS and acks without a part return (celery/worker/request.py:714-724). - After the part return took the claim (
celery/backends/redis.py:968) and before the body was sent (.jfull), the main process acks the same way, and nothing retries once the claim expires.
The window has a median of 4.8 ms with 4 headers of 100 B, 20 to 41 ms with 50 of 20 KB.
The main process knows its child stored SUCCESS (request.py:716). Running the part return there (counted once since #10919), and letting it take over a claim whose owner is gone, would close both. If the maintainers agree, I can send that as a PR with tests that fail on main.
Activity
auvipy commentedon Nov 8, 2026
Is this a regression or a old bug?
ChristianMurphy commentedon Nov 8, 2026
It's a regression in 5.7.0, from #10752. Before it, a pool process lost after the header stored SUCCESS either got the header run again, which completed the chord, or failed the chord with its errback. Since #10752 the worker sees the stored SUCCESS and acks the message without the chord part return, so that header is never counted and the chord stays PENDING.
acks_late+task_reject_on_worker_lost380b4a9, the commit before #10752e3cc7cc, #10752I missed this when I reviewed #10752. My runs killed the pool process from a
task_successreceiver, which runs aftermark_as_done()has stored SUCCESS and made the chord part return, so the header was already counted and the body ran. This issue needs the kill between those two steps. On main, killing fromtask_successruns the body 3 of 3 times, and killing before the part return leaves the chord PENDING 3 of 3 times.#10752 still looks right for plain tasks. For a chord header, the worker could make the part return itself when it finds SUCCESS stored, so the fix for #10724 holds and the chord completes. If that direction works for you, I'll put up a PR with a test that fails on main.
The kill timing
The app's result backend subclasses
RedisBackendand sends SIGKILL to the pool process at the start ofon_chord_part_return()for one header, once, after SUCCESS is stored. Each chord has four headers. The body's state is read 15 s after the kill. The issue's random-kill and OOM runs hit the same window without a hook.Complete chord part return when pool child is lost after storing SUCCESS