Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Celery worker with gevent pool + Sentry logger = Deathlock #1341

Closed
amezhenin opened this issue May 2, 2013 · 5 comments
Closed

Celery worker with gevent pool + Sentry logger = Deathlock #1341

amezhenin opened this issue May 2, 2013 · 5 comments

Comments

@amezhenin
Copy link

I'm using Celery with Django integration. I discovered some troubles with new commit to my current project: Celery worker with gevent pool refused to handle new tasks. After short investigation, I found that 'sentry' log handler cause a problem:
settings.py:

 LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s '\
                      '%(process)d %(thread)d %(message)s'
        },
        'gunicorn_style': {
            'format': CELERYD_TASK_LOG_FORMAT,
            },
    },
    'handlers': {
        'console':{
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'gunicorn_style'
        },
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'sentry': {
            'level': 'WARNING',
            'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
        }
},
'loggers': {
    'django.request': {
        'handlers': ['mail_admins'],
        'level': 'ERROR',
        'propagate': True,
    },
    'raven': {
        'level': 'INFO',
        'handlers': ['console'],
        'propagate': False,
    },
    'sentry.errors': {
        'level': 'INFO',
        'handlers': ['console'],
        'propagate': False,
        },
    }
}
...
#I want verbose logs only for my apps
for i in MY_APPS:
    LOGGING['loggers'][i] = {
                             'handlers': ['console', 'sentry'],
                             'level': CONSOLE_LOGLEVEL,
                             'propagate': False,
                            }
LOGGING['loggers']['celery'] = {
                           'handlers': ['sentry'],
                           'level': CONSOLE_LOGLEVEL,
                           'propagate': True,
                          }
...

With 'handlers': ['console'] all works fine, but when I add 'sentry' handler celer+gevent worker start to behave as follows: take N tasks from broker, where N is concurrency level and then stops.

I run celery worker with this command:

python manage.py celery worker -Q celery_gevent -P gevent -c 20    

Note: deathlock shows with concurrency >= 3

$ pip freeze
Django==1.5
Fabric==1.6.0
South==0.7.6
amqp==1.0.9
anyjson==0.3.3
argparse==1.2.1
billiard==2.7.3.22
celery==3.0.16
cssselect==0.8
distribute==0.6.24
django-appconf==0.6
django-celery==3.0.11
django-geoip==0.3
django-nose==1.1
django-redis==3.2
flower==0.5.0
gevent==0.13.8
greenlet==0.4.0
gunicorn==0.17.2
ipython==0.13.1
kombu==2.5.7
logilab-astng==0.24.2
logilab-common==0.59.0
lxml==3.1.1
nose==1.2.1
paramiko==1.10.0
progressbar==2.3dev
psycopg2==2.4.6
pycrypto==2.6
pylint==0.27.0
pymongo==2.4.2
python-dateutil==1.5
pytz==2013b
raven==3.2.0
redis==2.7.2
requests==1.0.4
six==1.3.0
tornado==3.0.1
wsgiref==0.1.2

Thank you.

@amezhenin
Copy link
Author

btw, I'm using RabbitMQ as broker and redis as result backend

@ask
Copy link
Contributor

ask commented May 14, 2013

Probably the sentry handler is not gevent compatible and is blocking the eventloop?

@amezhenin
Copy link
Author

David Cramer proposed to use gevent+http as transport for raven and it seams to work (getsentry/raven-python#305). May be you should mention this problem/solution somewhere in documentation.

@ask
Copy link
Contributor

ask commented May 30, 2013

Not sure there's any section in the docs where it's relevant and such that the user will find it :/

@ask ask closed this as completed May 30, 2013
@ask
Copy link
Contributor

ask commented May 30, 2013

Maybe the eventlet pool docs (there's none for gevent at this point)

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

No branches or pull requests

2 participants