Skip to content

DelayedDelivery Step Connection is left open without closing #9792

@bityob

Description

@bityob

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: 5.5.3

celery report Output:

software -> celery:5.5.3 (immunity) kombu:5.5.4 py:3.13.3
            billiard:4.2.1 py-amqp:5.3.1
platform -> system:Linux arch:64bit, ELF
            kernel version:5.15.153.1-microsoft-standard-WSL2 imp:CPython
loader   -> celery.loaders.app.AppLoader
settings -> transport:amqp results:disabled

broker_url: 'amqp://rabbitmq:********@localhost:5672/vhost'
deprecated_settings: None
worker_send_task_events: False
result_backend: None
worker_enable_remote_control: False
task_default_queue_type: 'quorum'
task_default_exchange_type: 'topic'

Steps to Reproduce

Required Dependencies

  • Minimal Python Version: N/A or Unknown
  • Minimal Celery Version: 5.5
  • 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:

amqp==5.3.1
billiard==4.2.1
celery==5.5.3
click==8.2.1
click-didyoumean==0.3.1
click-plugins==1.1.1.2
click-repl==0.3.0
kombu==5.5.4
packaging==25.0
prompt_toolkit==3.0.51
python-dateutil==2.9.0.post0
six==1.17.0
tzdata==2025.2
vine==5.1.0
wcwidth==0.2.13

Other Dependencies

Details

N/A

Minimally Reproducible Test Case

Details

# app.py
from celery import Celery

app = Celery('app', broker='amqp://rabbitmq:*****@localhost/vhost')
app.conf.worker_send_task_events = False
app.conf.result_backend = None
app.conf.worker_enable_remote_control = False
app.conf.task_default_queue_type = "quorum"
app.conf.task_default_exchange_type = "topic"

@app.task
def noop():
    pass

Expected Behavior

The write connection for creating the bind for quorum queues (DelayedDelivery step) should be closed after creation.

Actual Behavior

Running the Celery application with quorum queue, is creating one connection for tasks consuming as expected, and another connection for binding queues for delayed delivery exchange, but without closing the second connection.

uvx --with celery==5.5.3 celery -A app worker --loglevel=debug --without-gossip --without-mingle --without-heartbeat --prefetch-multiplier=1 --concurrency=1

Image
Image

The first connection here is for tasks consuming (you can see it by the prefetch column on the channel) and the second connection is for queue binding.

And from the logs -

Image

Indeed in the code we can the connection is created without closing -

Image

If we run Celery application with classic queue instead, indeed only one connection is created -

Image

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions