Repository navigation
Description
Celery version 3.1.22
In our web performance testing, Celery worker connection with Rabbitmq met broken pipe error IN Gevent Mode, while no problem when Celery worker work in Process pool mode.
After that, Celery workers will not get task messages from Rabbitmq anymore until they are restarted.
That issue always happen when the speed of Celery workers consuming task messages slower than Django applications producing messages, and about 3 thounds of messages piled in Rabbitmq.
Is that due to Gevent Monkey Patch?
====== Celery log ======
[2016-08-08 13:52:06,913: CRITICAL/MainProcess] Couldn't ack 293, reason:error(32, 'Broken pipe')
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/kombu/message.py", line 93, in ack_log_error
self.ack()
File "/usr/local/lib/python2.7/site-packages/kombu/message.py", line 88, in ack
self.channel.basic_ack(self.delivery_tag)
File "/usr/local/lib/python2.7/site-packages/amqp/channel.py", line 1584, in basic_ack
self._send_method((60, 80), args)
File "/usr/local/lib/python2.7/site-packages/amqp/abstract_channel.py", line 56, in _send_method
self.channel_id, method_sig, args, content,
File "/usr/local/lib/python2.7/site-packages/amqp/method_framing.py", line 221, in write_method
write_frame(1, channel, payload)
File "/usr/local/lib/python2.7/site-packages/amqp/transport.py", line 182, in write_frame
frame_type, channel, size, payload, 0xce,
File "/usr/local/lib/python2.7/site-packages/gevent/_socket2.py", line 412, in sendall
timeleft = self.__send_chunk(chunk, flags, timeleft, end)
File "/usr/local/lib/python2.7/site-packages/gevent/_socket2.py", line 351, in __send_chunk
data_sent += self.send(chunk, flags)
File "/usr/local/lib/python2.7/site-packages/gevent/_socket2.py", line 320, in send
return sock.send(data, flags)
error: [Errno 32] Broken pipe
======= Rabbitmq log ==================
=ERROR REPORT==== 8-Aug-2016::14:28:33 ===
closing AMQP connection <0.15928.4> (10.26.39.183:60732 -> 10.26.39.183:5672):
{writer,send_failed,{error,enotconn}}
=ERROR REPORT==== 8-Aug-2016::14:29:03 ===
closing AMQP connection <0.15981.4> (10.26.39.183:60736 -> 10.26.39.183:5672):
{writer,send_failed,{error,enotconn}}
=ERROR REPORT==== 8-Aug-2016::14:29:03 ===
closing AMQP connection <0.15955.4> (10.26.39.183:60734 -> 10.26.39.183:5672):
{writer,send_failed,{error,enotconn}}
Activity
ask commentedon Aug 9, 2016
This is probably fixed in master
jcyrss commentedon Aug 10, 2016
I tried with 4.x RC and met some issues
when I conduct load test, new issue appears as the following log shows.
Celery beat does not work, as the following log shows
I can't belive it will make rabbitmq web manage page of queue raise exception.
But that seem really cause by installing Celery 4RC, if I reinstall Celery 3.x, that page works again.
The following is what it complains in web manage page of Rabbitmq.
jcyrss commentedon Aug 12, 2016
Hi, maybe I found one clue to reproduce that.
That issue alway happen when the speed of Celery workers consuming task messages slower than Django applications producing messages, and about 3 thounds of messages piled in Rabbitmq.
qinshuang commentedon Aug 22, 2016
I met the same problem, Is it fixed?
jamestrose2 commentedon Oct 25, 2016
I am also seeing this issue with the most recent build, and I think it might have something to do with Django and exception handling. Has anyone developed a solution or workaround?
robsonpeixoto commentedon Dec 3, 2016
I'm having a similar bug with celery 4.0.0 #3649
alanhamlett commentedon Jan 9, 2017
nhaas-twist commentedon Mar 2, 2017
Same. Was fine under Celery 3.x. Broken pipe under 4.0.2.
leobuskin commentedon Aug 22, 2017
Can confirm @jcyrss - same, when Django produces messages faster than Celery workers consuming, not sure is it gevent monkey patch or not, but now trying to find a solution, first step - multiplying celery instances
vesterbaek commentedon Oct 9, 2017
Also seeing this with 4.1.0 and rabbitmq
hoozecn commentedon Oct 25, 2017
Having the same prob with celery 4.0.2 + gevent + python3
listingmirror commentedon Nov 1, 2017
I see this in prefork under high load
canassa commentedon Nov 1, 2017
This issue happens if the machine is starving for resources, what probably happens is that the internal state machine of gevent gets too busy and the events get too delayed therefore causing all kinds of issues, broken pipes, closed sockets, etc.
I had this issue for several weeks and I tried all sorts of workarounds for it (including replacing gevent, upgrading Celery from 3 to 4, etc), and what ultimately fixed the problem was upgrading the EC2 instance too a much bigger one and keeping a close on it to make that the load is never 100% for too long. I have never had any problems since then.
I don't think this is a issue with Celery per se so I would suggest the maintainers of Celery to close this issue and others similar to this. But adding some documentation about this on a best practices page would be a nice add-on to the project.
listingmirror commentedon Nov 1, 2017
@canassa what is starved for resources here?
I have my rabbitmq box in kubernetes on a very very very big machine. I limit it to 8GB of ram, and no CPU limit. Memory usage sits at maybe 2 GB. Anything in specific I should be looking for?
33 remaining items
madchap commentedon May 28, 2020
Still happening in 4.4.2 apparently. I am hit by this.
auvipy commentedon May 28, 2020
feel free to test and update the unit test for the linked patch
Honst211 commentedon Nov 28, 2020
This problem still exists in 4.4.7
alex-milanovic commentedon Dec 21, 2020
Getting this in 5.0.2. Seems to be failing outside my
@app.taskso can't use atrystatement to catch itozgurakcali commentedon Jul 29, 2021
I've also been getting these errors with celery / rabbitmq / gevent workers. I've increased the resources on the server, so that max cpu usage hits at most around 50%, but still got these errors. Tried different concurrency levels between 4 and 128 with no help.
celery==5.1.2
gevent==21.1.2
amqp ==5.0.6
rabbitmq: AWS managed service
Also, this does not happen with our dev environment, tasks there run on a much smaller db, so issuing much less db queries and external requests, I imagine this issue might have something to do with task loads.
We decided not to use gevent workers, but switched to threads workers, still enabling us more concurrency at less resource usage when compared to prefork workers, at the expense of possible less efficiency of os task scheduler when compared to gevent event loop.
idanmantin commentedon Oct 8, 2021
Having the same issue:
Running
supervisord,celery==4.3.0with gevent workers.gevent==1.4.0amqp==2.5.0kombu==4.6.3The worker is stuck, although supervisord is configured with
autorestart=trueand should take care of restarting.Reason:
kombunot handling BrokenPipeError, that was fixed in version: v5.2.0rc1This solved the problem:
https://github.com/celery/kombu/blob/0253cfb7b2379b2a4290ee663d40f55c03147f99/kombu/message.py#L129-L132
auvipy commentedon Oct 8, 2021
you should upgrade to celery 5.2.0rc1 for that.
vladjkeeee13 commentedon Mar 30, 2023
Got the same error.
Try to increase memory for this worker. It helped in my case.