Ben G
Ben G

Reputation: 3975

Celery + SQLAlchemy : DatabaseError: (DatabaseError) SSL error: decryption failed or bad record mac

Error in the title triggers sometimes when using celery with more than one worker on a postgresql db with SSL turned on. I'm in a flask + SQLAlchemy configuration

Upvotes: 3

Views: 2196

Answers (1)

Ben G
Ben G

Reputation: 3975

As mentionned here : https://github.com/celery/celery/issues/634 the solution in the django-celery plugin was to simply dispose all db connection at the start of the task.

In flask + SQLAlchemy configuration, doing this worked for me :

from celery.signals import task_prerun

@task_prerun.connect
def on_task_init(*args, **kwargs):
    engine.dispose()

in case you don't know what "engine" is and how to get it, see here : http://flask.pocoo.org/docs/patterns/sqlalchemy/

Upvotes: 4

Related Questions