Skip to content

Chord stays PENDING forever when a pool process is lost after a header stored SUCCESS #11038

Open

Description

@ChristianMurphy

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 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.
  • 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

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 (.j one 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 (.j full), 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

  1. auvipy commented on Nov 8, 2026

    @auvipy
    Member

    Is this a regression or a old bug?

  2. ChristianMurphy commented on Nov 8, 2026

    @ChristianMurphy
    ContributorAuthor

    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.

    Pool process killed right after the header stored SUCCESS (Redis broker and results, prefork) acks_late + task_reject_on_worker_lost default early ack
    5.5.3 body ran, 3 of 3 chord failed, errback ran, 3 of 3
    5.6.3 body ran, 3 of 3 chord failed, errback ran, 3 of 3
    380b4a9, the commit before #10752 body ran, 2 of 2 chord failed, errback ran, 2 of 2
    e3cc7cc, #10752 PENDING, 2 of 2 PENDING, 2 of 2
    main PENDING, 3 of 3 PENDING, 3 of 3

    I missed this when I reviewed #10752. My runs killed the pool process from a task_success receiver, which runs after mark_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 from task_success runs 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 RedisBackend and sends SIGKILL to the pool process at the start of on_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.

  3. added a commit that references this issue on Nov 27, 2026
    a142c04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions