Skip to content

The celery beat are not sending the heartbeat when are using gevent #3649

Closed

Description

@robsonpeixoto

If you keep the process in idle, it will show this error:

The RabbitMQ(RabbitMQ 3.6.6, Erlang 19.0.7) show this error:

rabbitmq_1  | =ERROR REPORT==== 3-Dec-2016::19:28:52 ===
rabbitmq_1  | closing AMQP connection <0.2500.1> (172.19.0.4:42882 -> 172.19.0.3:5672):
rabbitmq_1  | missed heartbeats from client, timeout: 60s

And the celery Traceback:

celery_1    | [2016-12-03 17:28:52,147: WARNING/MainProcess] Traceback (most recent call last):
celery_1    | [2016-12-03 17:28:52,150: WARNING/MainProcess] File "/usr/local/lib/python3.5/site-packages/gevent/hub.py", line 846, in switch
celery_1    |     switch(value)
celery_1    | [2016-12-03 17:28:52,153: WARNING/MainProcess] File "/usr/local/lib/python3.5/site-packages/celery/worker/pidbox.py", line 116, in loop
celery_1    |     connection.drain_events(timeout=1.0)
celery_1    | [2016-12-03 17:28:52,154: WARNING/MainProcess] File "/usr/local/lib/python3.5/site-packages/kombu/connection.py", line 301, in drain_events
celery_1    |     return self.transport.drain_events(self.connection, **kwargs)
celery_1    | [2016-12-03 17:28:52,156: WARNING/MainProcess] File "/usr/local/lib/python3.5/site-packages/kombu/transport/pyamqp.py", line 103, in drain_events
celery_1    |     return connection.drain_events(**kwargs)
celery_1    | [2016-12-03 17:28:52,158: WARNING/MainProcess] File "/usr/local/lib/python3.5/site-packages/amqp/connection.py", line 464, in drain_events
celery_1    |     return self.blocking_read(timeout)
celery_1    | [2016-12-03 17:28:52,158: WARNING/MainProcess] File "/usr/local/lib/python3.5/site-packages/amqp/connection.py", line 468, in blocking_read
celery_1    |     frame = self.transport.read_frame()
celery_1    | [2016-12-03 17:28:52,159: WARNING/MainProcess] File "/usr/local/lib/python3.5/site-packages/amqp/transport.py", line 223, in read_frame
celery_1    |     frame_header = read(7, True)
celery_1    | [2016-12-03 17:28:52,161: WARNING/MainProcess] File "/usr/local/lib/python3.5/site-packages/amqp/transport.py", line 363, in _read
celery_1    |     s = recv(n - len(rbuf))
celery_1    | [2016-12-03 17:28:52,162: WARNING/MainProcess] File "/usr/local/lib/python3.5/site-packages/gevent/_socket3.py", line 313, in recv
celery_1    |     return _socket.socket.recv(self._sock, *args)
celery_1    | [2016-12-03 17:28:52,162: WARNING/MainProcess] ConnectionResetError: [Errno 104] Connection reset by peer
celery_1    | [2016-12-03 17:28:52,163: WARNING/MainProcess] <built-in method switch of greenlet.greenlet object at 0x7efedbf853d8> failed with ConnectionResetError

More info about the environment:

root@5631e10b158e:/usr/src/app# celery -A notification report

software -> celery:4.0.0 (latentcall) kombu:4.0.0 py:3.5.2
            billiard:3.5.0.2 py-amqp:2.1.1
platform -> system:Linux arch:64bit, ELF imp:CPython
loader   -> celery.loaders.app.AppLoader
settings -> transport:amqp results:disabled

include: ['notification.tasks']
broker_url: 'amqp://guest:********@rabbitmq:5672//'
task_default_queue: 'notification'
root@5631e10b158e:/usr/src/app# celery -A notification report
amqp (2.1.1)
billiard (3.5.0.2)
celery (4.0.0)
click (6.6)
Flask (0.11.1)
gevent (1.1.2)
greenlet (0.4.10)
gunicorn (19.6.0)
itsdangerous (0.24)
Jinja2 (2.8)
kombu (4.0.0)
MarkupSafe (0.23)
notification (1.0, /usr/src/app)
pip (9.0.1)
python-decouple (3.0)
pytz (2016.7)
requests (2.12.3)
setuptools (30.1.0)
toolz (0.8.0)
vine (1.1.3)
Werkzeug (0.11.11)

The celery was executed with the command: celery -A notification worker -P gevent -c 8 -l info

Activity

  1. emilhdiaz commented on Dec 6, 2016

    @emilhdiaz

    I'm also experiencing the same issue with the gevent pool. Here is my report output:

    software -> celery:4.0.0 (latentcall) kombu:4.0.0 py:2.7.6
                billiard:3.5.0.2 py-amqp:2.1.1
    platform -> system:Linux arch:64bit, ELF imp:CPython
    loader   -> celery.loaders.app.AppLoader
    settings -> transport:amqp results:disabled
    
    CELERY_ACKS_LATE: True
    CELERYD_PREFETCH_MULTIPLIER: 1
    CELERY_RESULT_SERIALIZER: 'json'
    CELERY_ACCEPT_CONTENT: ['json']
    CELERY_IMPORTS: 
        ('app.tasks.dashboard',
     'app.tasks.metabase',
     'app.tasks.parser',
     'app.tasks.products')
    BROKER_POOL_LIMIT: None
    urllib: <module 'urllib' from '/usr/lib/python2.7/urllib.pyc'>
    BROKER_URL: u'amqp://celery:********@localhost:5672//'
    CELERYD_HIJACK_ROOT_LOGGER: False
    CELERY_IGNORE_RESULT: True
    CELERYD_TASK_SOFT_TIME_LIMIT: 5
    CELERYD_TASK_TIME_LIMIT: 60
    CELERY_TASK_SERIALIZER: 'json'
    

    and the exception stack trace:

    WARNING 2016-12-06 01:50:26,902 log 2424 139719650135568 Traceback (most recent call last):
    WARNING 2016-12-06 01:50:26,902 log 2424 139719650135568 File "/srv/www/app/shared/env/local/lib/python2.7/site-packages/gevent/hub.py", line 846, in switch
    WARNING 2016-12-06 01:50:26,903 log 2424 139719650135568 switch(value)
    WARNING 2016-12-06 01:50:26,903 log 2424 139719650135568 File "/srv/www/app/shared/env/local/lib/python2.7/site-packages/celery/worker/pidbox.py", line 116, in loop
    WARNING 2016-12-06 01:50:26,903 log 2424 139719650135568 connection.drain_events(timeout=1.0)
    WARNING 2016-12-06 01:50:26,903 log 2424 139719650135568 File "/srv/www/app/shared/env/local/lib/python2.7/site-packages/kombu/connection.py", line 301, in drain_events
    WARNING 2016-12-06 01:50:26,904 log 2424 139719650135568 return self.transport.drain_events(self.connection, **kwargs)
    WARNING 2016-12-06 01:50:26,904 log 2424 139719650135568 File "/srv/www/app/shared/env/local/lib/python2.7/site-packages/kombu/transport/pyamqp.py", line 103, in drain_events
    WARNING 2016-12-06 01:50:26,904 log 2424 139719650135568 return connection.drain_events(**kwargs)
    WARNING 2016-12-06 01:50:26,904 log 2424 139719650135568 File "/srv/www/app/shared/env/local/lib/python2.7/site-packages/amqp/connection.py", line 464, in drain_events
    WARNING 2016-12-06 01:50:26,904 log 2424 139719650135568 return self.blocking_read(timeout)
    WARNING 2016-12-06 01:50:26,905 log 2424 139719650135568 File "/srv/www/app/shared/env/local/lib/python2.7/site-packages/amqp/connection.py", line 468, in blocking_read
    WARNING 2016-12-06 01:50:26,905 log 2424 139719650135568 frame = self.transport.read_frame()
    WARNING 2016-12-06 01:50:26,905 log 2424 139719650135568 File "/srv/www/app/shared/env/local/lib/python2.7/site-packages/amqp/transport.py", line 223, in read_frame
    WARNING 2016-12-06 01:50:26,905 log 2424 139719650135568 frame_header = read(7, True)
    WARNING 2016-12-06 01:50:26,906 log 2424 139719650135568 File "/srv/www/app/shared/env/local/lib/python2.7/site-packages/amqp/transport.py", line 363, in _read
    WARNING 2016-12-06 01:50:26,906 log 2424 139719650135568 s = recv(n - len(rbuf))
    WARNING 2016-12-06 01:50:26,906 log 2424 139719650135568 File "/srv/www/app/shared/env/local/lib/python2.7/site-packages/gevent/_socket2.py", line 274, in recv
    WARNING 2016-12-06 01:50:26,906 log 2424 139719650135568 return sock.recv(*args)
    WARNING 2016-12-06 01:50:26,906 log 2424 139719650135568 error: [Errno 104] Connection reset by peer
    WARNING 2016-12-06 01:50:26,907 log 2424 139719650135568 <built-in method switch of greenlet.greenlet object at 0x7f12dd269f50> failed with error
    
  2. robsonpeixoto commented on Dec 7, 2016

    @robsonpeixoto
    Author

    @ask Are there plans of a near release with bug fixes?

  3. amirrustam commented on Dec 9, 2016

    @amirrustam
    Contributor

    I disabled heartbeats to temporarily "deal" with this issue. Workers don't seem to sending heart beats to RabbitMQ.

  4. failedguidedog commented on Mar 23, 2017

    @failedguidedog

    @ask Was this problem fixed in 4.0.2?

    I'm asking because we're running a similar environment as the OP, with eventlet pools, and we're seeing a lot of this errors: (more details in the sentry log:
    celery_control_command_error_connectionreseterror.json.txt)

    Stacktrace (most recent call last):
    
      File "celery/worker/pidbox.py", line 42, in on_message
        self.node.handle_message(body, message)
      File "kombu/pidbox.py", line 129, in handle_message
        return self.dispatch(**body)
      File "kombu/pidbox.py", line 112, in dispatch
        ticket=ticket)
      File "kombu/pidbox.py", line 135, in reply
        serializer=self.mailbox.serializer)
      File "kombu/pidbox.py", line 265, in _publish_reply
        **opts
      File "kombu/messaging.py", line 181, in publish
        exchange_name, declare,
      File "kombu/messaging.py", line 203, in _publish
        mandatory=mandatory, immediate=immediate,
      File "amqp/channel.py", line 1748, in _basic_publish
        (0, exchange, routing_key, mandatory, immediate), msg
      File "amqp/abstract_channel.py", line 64, in send_method
        conn.frame_writer(1, self.channel_id, sig, args, content)
      File "amqp/method_framing.py", line 174, in write_frame
        write(view[:offset])
      File "amqp/transport.py", line 269, in write
        self._write(s)
    

    We've upgraded to 4.0.2 last weekend and this is causing a lot of sleepless nights :( Please help.

  5. added a commit that references this issue on Jun 11, 2018
    80900c1
  6. arvindnrbt commented on Aug 15, 2018

    @arvindnrbt

    Celery 4.2.1 I'm still facing this issue.
    RabbitMQ log

    rabbitmq_1  | =ERROR REPORT==== 15-Aug-2018::10:05:42 ===
    rabbitmq_1  | closing AMQP connection <0.28344.0> (172.18.0.5:46918 -> 172.18.0.3:5672):
    rabbitmq_1  | missed heartbeats from client, timeout: 60s
    

    Celery -A proj inspect active

    15-08-2018:10:08:41,476 DEBUG    [connection.py:360] Start from server, version: 0.9, properties: {'capabilities': {'publisher_confirms': True, 'exchange_exchange_bindings': True, 'basic.nack': True, 'consumer_cancel_notify': True, 'connection.blocked': True, 'consumer_priorities': True, 'authentication_failure_close': True, 'per_consumer_qos': True, 'direct_reply_to': True}, 'cluster_name': 'rabbit@09ef45b313ed', 'copyright': 'Copyright (C) 2007-2016 Pivotal Software, Inc.', 'information': 'Licensed under the MPL.  See http://www.rabbitmq.com/', 'platform': 'Erlang/OTP', 'product': 'RabbitMQ', 'version': '3.6.1'}, mechanisms: [b'AMQPLAIN', b'PLAIN'], locales: ['en_US']
    15-08-2018:10:08:41,490 DEBUG    [channel.py:106] using channel_id: 1
    15-08-2018:10:08:41,493 DEBUG    [channel.py:443] Channel open
    15-08-2018:10:08:41,516 DEBUG    [connection.py:360] Start from server, version: 0.9, properties: {'capabilities': {'publisher_confirms': True, 'exchange_exchange_bindings': True, 'basic.nack': True, 'consumer_cancel_notify': True, 'connection.blocked': True, 'consumer_priorities': True, 'authentication_failure_close': True, 'per_consumer_qos': True, 'direct_reply_to': True}, 'cluster_name': 'rabbit@09ef45b313ed', 'copyright': 'Copyright (C) 2007-2016 Pivotal Software, Inc.', 'information': 'Licensed under the MPL.  See http://www.rabbitmq.com/', 'platform': 'Erlang/OTP', 'product': 'RabbitMQ', 'version': '3.6.1'}, mechanisms: [b'AMQPLAIN', b'PLAIN'], locales: ['en_US']
    15-08-2018:10:08:41,521 DEBUG    [channel.py:106] using channel_id: 1
    15-08-2018:10:08:41,524 DEBUG    [channel.py:443] Channel open
    Error: No nodes replied within time constraint.
    

    After 5 min,
    RabbitMQ

    rabbitmq_1  | =WARNING REPORT==== 15-Aug-2018::10:10:30 ===
    rabbitmq_1  | closing AMQP connection <0.1904.1> (172.18.0.5:47004 -> 172.18.0.3:5672):
    rabbitmq_1  | client unexpectedly closed TCP connection
    

    celery -A proj inspect active

    15-08-2018:10:12:03,837 DEBUG    [connection.py:360] Start from server, version: 0.9, properties: {'capabilities': {'publisher_confirms': True, 'exchange_exchange_bindings': True, 'basic.nack': True, 'consumer_cancel_notify': True, 'connection.blocked': True, 'consumer_priorities': True, 'authentication_failure_close': True, 'per_consumer_qos': True, 'direct_reply_to': True}, 'cluster_name': 'rabbit@09ef45b313ed', 'copyright': 'Copyright (C) 2007-2016 Pivotal Software, Inc.', 'information': 'Licensed under the MPL.  See http://www.rabbitmq.com/', 'platform': 'Erlang/OTP', 'product': 'RabbitMQ', 'version': '3.6.1'}, mechanisms: [b'AMQPLAIN', b'PLAIN'], locales: ['en_US']
    15-08-2018:10:12:03,844 DEBUG    [channel.py:106] using channel_id: 1
    15-08-2018:10:12:03,848 DEBUG    [channel.py:443] Channel open
    15-08-2018:10:12:03,869 DEBUG    [connection.py:360] Start from server, version: 0.9, properties: {'capabilities': {'publisher_confirms': True, 'exchange_exchange_bindings': True, 'basic.nack': True, 'consumer_cancel_notify': True, 'connection.blocked': True, 'consumer_priorities': True, 'authentication_failure_close': True, 'per_consumer_qos': True, 'direct_reply_to': True}, 'cluster_name': 'rabbit@09ef45b313ed', 'copyright': 'Copyright (C) 2007-2016 Pivotal Software, Inc.', 'information': 'Licensed under the MPL.  See http://www.rabbitmq.com/', 'platform': 'Erlang/OTP', 'product': 'RabbitMQ', 'version': '3.6.1'}, mechanisms: [b'AMQPLAIN', b'PLAIN'], locales: ['en_US']
    15-08-2018:10:12:03,876 DEBUG    [channel.py:106] using channel_id: 1
    15-08-2018:10:12:03,879 DEBUG    [channel.py:443] Channel open
    -> celery@ocrworker: OK
        - empty -
    

    I'm running celery inside docker container and I'm worried about celery performing consistently with no downtime as we had Connection reset by peer error in our tests often. Please throw some light on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions