Repository navigation
Closed
Labels
Description
Apache Airflow version
main (development)
What happened
Worker seems to be stuck in a catatonic state where queued tasks instance messages are not consumed from redis.
Redis did restart while the worker remained as is. The worker did output logs that indicated a loss in connection but was able to reconnect after redis came back online.
[2022-09-19 23:58:00,794: ERROR/MainProcess] consumer: Cannot connect to redis://:**@accurate-axis-9558-redis:6379/0: Error 111 connecting to accurate-axis-9558-redis:6379. Connection refused..
Trying again in 2.00 seconds... (1/100)
[2022-09-19 23:58:03,802: ERROR/MainProcess] consumer: Cannot connect to redis://:**@accurate-axis-9558-redis:6379/0: Error 111 connecting to accurate-axis-9558-redis:6379. Connection refused..
Trying again in 4.00 seconds... (2/100)
[2022-09-19 23:58:08,830: ERROR/MainProcess] consumer: Cannot connect to redis://:**@accurate-axis-9558-redis:6379/0: Error 111 connecting to accurate-axis-9558-redis:6379. Connection refused..
Trying again in 6.00 seconds... (3/100)
[2022-09-19 23:58:15,866: ERROR/MainProcess] consumer: Cannot connect to redis://:**@accurate-axis-9558-redis:6379/0: Error 111 connecting to accurate-axis-9558-redis:6379. Connection refused..
Trying again in 8.00 seconds... (4/100)
[2022-09-19 23:58:24,890: ERROR/MainProcess] consumer: Cannot connect to redis://:**@accurate-axis-9558-redis:6379/0: Error 111 connecting to accurate-axis-9558-redis:6379. Connection refused..
Trying again in 10.00 seconds... (5/100)
[2022-09-19 23:58:34,907: INFO/MainProcess] Connected to redis://:**@accurate-axis-9558-redis:6379/0
[2022-09-19 23:58:34,915: INFO/MainProcess] mingle: searching for neighbors
[2022-09-19 23:58:35,923: INFO/MainProcess] mingle: all alone
What you think should happen instead
After redis comes back online and the worker connected again, the worker should consume the messages and execute queued task instances.
How to reproduce
- Delete the existing redis pod and the worker should be unable to connect to redis
- Redis restarts and the worker connects as expected
- Worker does not consume new messages (queued task instances)
Operating System
N/A
Versions of Apache Airflow Providers
No response
Deployment
Astronomer
Deployment details
No response
Anything else
There was a Github Discussion earlier this year about this behaviour.
This didn't seem to be an issue on an early version of celery (4.4.7).
The current installed version is celery==5.2.7 and I use redis versioned at 6.2.6.
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
Activity
ashb commentedon Sep 21, 2022
Hmmm, this feels like a Celery issue, as all
airflow celery workerdoes is run the celery app.(I'm not saying we shouldn't look at fixing it, just surprised that celery doesn't do it for us)
wolfier commentedon Sep 22, 2022
Yep! I linked the Github Discussion from celery Github.
This is more just a record to keep track of this behaviour.
wolfier commentedon Oct 16, 2022
The new liveness probe on the Celery Worker (#25561) doesn't fix the root issue but does put in safeguards to reset the worker when workers become catatonic.
Scorpion2115 commentedon Sep 4, 2023
I am having exactly the same issue with my Airflow 2.5.1
potiuk commentedon Sep 4, 2023
Are you using the official chart that has the safeguards as mentioned in ?
Scorpion2115 commentedon Sep 5, 2023
Sorry my Airflow was deployed on normal EC2 instances, not Kubernetes.
Is there any similar fix available?
9 remaining items
potiuk commentedon Jan 29, 2024
I think it depends if those are "Generically applicable".
I think a number of our users would still not use the latest celery, celery has quite a number of dependencies on it's own and it "adds" on top of the dependencies just plain airflow has. The problem with celery is that - similarly as in case of Airflow - the workers and dependencies of Celery share the same virtualenv that the task runs in, so there might be plenty of reasons why our users would like to use older celery version (in older Airflow) or maybe even downgrade celery version used even in future versions of Airlfow. Celery is pretty special because it generally impacts everyone running any task with any provider combinations, so I'd imagine it migh be much harder to expect people to upgrade it to 5.4.0.
So I think if we ALSO have a way how to bring older celery configuration to "reasonable defaults", it's worth considering to explain that in the documentation and even our Helm Chart, and I am even happy to to it myself @dstandish @eladkal , but I need to know if those are defaults that are "ok" to be considered as sane defaults.
potiuk commentedon Jan 29, 2024
And just to add a bit more context to the discussion. It's a known fact that a number of our users have some troubles with stability running Celery-based deployment. I think if we know a way to make it more stable, keeping it as "secret-sauce" makes little sense. Also some people proposed other solutions to improve stability (which might or might not be related and they are way more invasive) and possibly the stability issues might be helped with better default configuration (in docs and in chart).
I am particualarly referring to that one #31829 which proposes to disable the "ack late" feature to improve stability of Airflow Celery deployment, which comes from the creator of the "user community" chart. We - so far - generally ignored that one, mostly I guessm becasue we did not want to spend time on analysing all the consequences of disabling ack late.
I personally have a feeling that it changes a lot of promises about delivery and taks handling in Celery, and shifts the problem to other set of edge cases, but maybe, by making the defaults working "better" out-of-the-box, the reason for the "ack late disabling" migh be generally gone as that might improve Celery deployment stability?
That's just a thought and more context, the "ack late" ase bothers me for quite some time, but I do not have enough experience/knowledge in Celery to be able to provide more than just intuition, that maybe this one applied properly might solve problems that manifest in others trying other, worse effectively, things to improve the stability of celery.
potiuk commentedon Jan 29, 2024
And the new PR for "ack_late" - to complete the picture: #37066
eladkal commentedon Jan 30, 2024
I am OK with it.
If we don't know the values yet we can refer from the docs to this issue (or to github discussion) where we explain consideration and suggest a few options while letting the community to comment and participate in the discussion.
alex-trm commentedon Jan 21, 2025
The discussion that @wolfier linked originally celery/celery#7276, has since been closed reporting that the issue is fixed in Celery >= 5.5.X. I'm going to test this and report back. People reported in the most recent comments of that discussion that upgrading has resolved this. Really hoping that this is the case!
celery/kombu#2007
potiuk commentedon Jan 21, 2025
Please do !
alex-trm commentedon Jan 21, 2025
I am able to reliably reproduce the issue using the official Helm chart. I haven't been able to do this before so I'd like to document the process here:
statefulsetto 0 replicasstatefulsetto 1 replicaThis seems to reliably disconnect the worker from Redis (expected, since the Redis pod is going down) and then reconnect the worker to Redis without the ability to run tasks. Shouldn't take 2-3 cycles of the above steps to trigger the catatonic state where the worker says that it's connected, isn't killed by the liveness probe, but can't accept tasks from the queue.
I thought that it would be easier to just delete the Redis pod and have it restart without changing the number of replicas but that doesn't seem to do the trick. The
kombulink I posted above mentions GC issues and I'm wondering if keeping Redis down for ~10 seconds is long enough for a few connection retries and maybe a GC loop but not so long that the liveness probe kills the worker. Regardless, these steps seem to reliably reproduce the issue.Next I will upgrade to
celery==5.5.0rc4and try that process againalex-trm commentedon Jan 23, 2025
I upgraded to
celery==5.5.0rc4and ran my reproduction scenario 3x. Every time the worker reconnected after Redis restarted it was able to start running tasks again. I actually think celery/kombu#2007 may have resolved the issue for Airflow Celery Executor using Redis as a queue!@potiuk What other testing do you think would be required for this? I'm going to upgrade our staging environment to this version and let it bake for a while.
eladkal commentedon Jan 23, 2025
Noting we have #43777 waiting for the 5.5.0 release
alex-trm commentedon Jan 23, 2025
We're going to modify constraints to use rc4 for now to give it some time to test in staging / prod and I'll keep updating here with findings if we have any problems that continue after an upgrade w.r.t. this issue.
alex-trm commentedon Jan 23, 2025
Would you rather have comments here or in PR?
potiuk commentedon Jan 25, 2025
Whatever. But best if you comment in Celery repo so that they finally release it if you confirm it fixes the issue :)
alex-trm commentedon Feb 21, 2025
We were able to test and confirm that in production this resolved our catatonic worker issue. Looking forward to seeing the full release of 5.5 so we can get this into Airflow officially. @wolfier I think we may finally be done with the catatonic worker issue 💯
eladkal commentedon Feb 21, 2025
This up to Celery to release it. I suggest to check with them if they can expedite release.