Repository navigation
Closed
Closed
Copy link
Labels
area:corearea:providersgood first issuekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yetprovider:celery
Description
Apache Airflow Provider(s)
celery
Versions of Apache Airflow Providers
3.14.1
Apache Airflow version
3.1.5
Operating System
WSL Ubuntu 22.04
Deployment
Virtualenv installation
Deployment details
Installed with UV:
uv pip install "apache-airflow[celery]==3.1.5" --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-3.1.5/constraints-3.12.txt"
What happened
When starting a Celery worker with a custom --celery-hostname, the worker successfully connects to the broker and reserves tasks, but never executes them.
The task stays in reserved state with:
acknowledged: False
worker_pid: None
time_start: None
Removing --celery-hostname and using the default hostname makes everything work correctly.
Output when using --celery-hostname:
(.venv) me@DESKTOP-MAG5124:~/airflow$ celery -A airflow.providers.celery.executors.celery_executor_utils.app inspect reserved
-> default@DESKTOP-MAG5124: OK
* {'id': '923f016a-a3da-42c2-bf57-4f4193e11721', 'name': 'execute_workload', 'args': ['{"token":"token_here","task_id":"get_airflow_variables","dag_id":"dirbg_crawler","run_id":"manual__2025-12-22T07:57:45+00:00","try_number":2,"map_index":-1,"pool_slots":1,"queue":"default","priority_weight":2,"parent_context_carrier":{},"context_carrier":{}},"dag_rel_path":"dirbg_crawler.py","bundle_info":{"name":"dags-folder","version":null},"log_path":"dag_id=dirbg_crawler/run_id=manual__2025-12-22T07:57:45+00:00/task_id=get_airflow_variables/attempt=2.log","type":"ExecuteTask"}'], 'kwargs': {}, 'type': 'execute_workload', 'hostname': 'default@DESKTOP-MAG5124', 'time_start': None, 'acknowledged': False, 'delivery_info': {'exchange': '', 'routing_key': 'default', 'priority': 0, 'redelivered': False}, 'worker_pid': None}
1 node online.
(.venv) me@DESKTOP-MAG5124:~/airflow$ celery -A airflow.providers.celery.executors.celery_executor_utils.app inspect active_queues
-> default@DESKTOP-MAG5124: OK
* {'name': 'default', 'exchange': {'name': 'default', 'type': 'direct', 'arguments': None, 'durable': True, 'passive': False, 'auto_delete': False, 'delivery_mode': None, 'no_declare': False}, 'routing_key': 'default', 'queue_arguments': None, 'binding_arguments': None, 'consumer_arguments': None, 'durable': True, 'exclusive': False, 'auto_delete': False, 'no_ack': False, 'alias': None, 'bindings': [], 'no_declare': None, 'expires': None, 'message_ttl': None, 'max_length': None, 'max_length_bytes': None, 'max_priority': None}
1 node online.
Output when NOT using --celery-hostname:
Note: The task is already executing.
(.venv) dani@DESKTOP-MAG5124:~/airflow$ celery -A airflow.providers.celery.executors.celery_executor_utils.app inspect reserved
-> celery@DESKTOP-MAG5124: OK
- empty -
What you think should happen instead
Worker should execute reserved tasks regardless of custom hostname.
How to reproduce
This does NOT work - task reserved but never executed
airflow celery worker \
--queues my_queue \
--concurrency 1 \
--celery-hostname "myworker@%h"
This is valid even if you set the --celery-hostname to "celery@%h" which should be the default option.
This WORKS
airflow celery worker \
--queues my_queue \
--concurrency 1
Anything else
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Reacted by Bruno Macedo, mxmua and franko14
Metadata
Metadata
Assignees
Labels
area:corearea:providersgood first issuekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yetprovider:celery
Activity
CreeperBeatz commentedon Dec 22, 2025
I just tested downgrading to Celery Providers 3.13.1, and the issue DOES NOT exist there. This is something that happened in the 3.14.* release of the celery providers.
brunocmacedo commentedon Dec 23, 2025
After a couple hours trying to find what was the issue after 3.1.5 upgrade I found this and can confirm that I have the same issue with apache-airflow-providers-celery 3.14.1. Falling back to 3.13.1 solved the issue for now.
As a reference, here is the airflow-worker definition in my docker compose. In my case i need to set celery-hostname due to the three replicas being used.
sonbaoharryson commentedon Jan 21, 2026
thanks @brunocmacedo , i did same things you provided, worked for me!!!
mxmua commentedon Feb 17, 2026
Same issue on v3.1.7 with apache-airflow-providers-celery 3.15.2.
Works fine without --celery-hostname
vikasgrover2 commentedon Feb 26, 2026
man the headache this caused. Not even ai could figure out what was going on until I stumbled into this thread.
mszmidt commentedon Mar 5, 2026
Yeah, it was a huge pain... For us it started with 3.1.3 I believe. And took ~2 weeks to find this issue and alter config. (Self-built docker images installed with pipx) In the meantime we changed everything including Dockerfiles...
Fix --celery-hostname causing workers to reserve but never execute tasks
Add deep analysis files for 3 open Airflow issues
Add investigation docs for celery-hostname issue apache#59707
Fix Celery worker not executing tasks when using --celery-hostname
Add producer pool state logging to confirm root cause of apache#59707
Fix Celery worker stuck tasks by resetting producer pool after inspect
Remove duplicate hostname check that causes stale pool inheritance
Add comprehensive Celery state dump script for apache#59707 investiga…
Add comprehensive investigation report and fork FD tracer for apache#…
shivaam commentedon Mar 23, 2026
I did some testing and tried to replicate the issue on my end. I think commit
16829d7694— "Add duplicate hostname check for Celery workers (#58591)" — landed in celery provider 3.14.0. This is the only CLI change between 3.13.1 and 3.14.0, consistent with reports that downgrading to 3.13.1 fixes the issue.Root Cause
The duplicate hostname check calls
celery_app.control.inspect().active_queues()beforecelery_app.worker_main(). Theinspect()call opens broker connections and initializes internal connection/producer pools on the Celery app. Whenworker_main()starts the worker with thepreforkpool (which usesfork()), this pre-initialized state interferes with the worker's internal communication — tasks are received from the broker but never dispatched to pool workers.I confirmed this by observing that
app.amqp._producer_poolis non-None atworker_main()time when the bug occurs, and None when it works correctly. Clearing this state withkombu.pools.reset()after theinspect()call restores correct behavior.I have not fully traced the exact internal mechanism by which the pre-initialized pools break the prefork dispatch path, but the correlation is consistent across all tests.
Fixes That Work (verified on live Airflow 3.2 + Celery 5.6.2 + Redis)
Option A — Remove the duplicate hostname check entirely. Simplest fix, minor UX loss (no warning if you accidentally start two workers with the same hostname). Tested and confirmed working.
Option B — Use a temp app +
kombu.pools.reset(): Keeps the check, cleans up connection state beforeworker_main():The
kombu.pools.reset()is essential —kombu.poolsis a process-global registry keyed by broker URL, so even a separate temp app's connections end up in the same global pool.Approaches That Did Not Work
app.amqp._producer_pool = Noneonlykombu.poolsstill holds statekombu.pools.reset()app.pool.force_close_all()Investigation branch with diagnostic scripts:
investigate/celery-hostname-59707shivaam commentedon Mar 23, 2026
@dheerajturaga Do you have any idea why the duplicate check might be causing this isuse? Is it fine if we remove the check?
@hussein-awala wondering if you have any thoughts on this?
shivaam commentedon Apr 2, 2026
@auvipy wondering if you have any thoughts on this issue. Any inputs on what we can check further?