Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 826
Ben G Avatar asked Jun 14 '26 15:06

Ben G


1 Answers

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/

like image 181
Ben G Avatar answered Jun 17 '26 21:06

Ben G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!