OperationalError: SSL error: decryption failed or bad record mac
See original GitHub issueNot sure if this is a django-rq issue or python-rq, so I figured I’d start here…
My application was working perfectly under Django 1.7.x.
I updated to Django 1.8.x and my workers blew up.
WARNING 11:29:35 worker 16516 140021590959936 Moving job to u'failed' queue
WARNING 2015-08-30 11:29:35,394 worker 16516 140021590959936 Moving job to u'failed' queue
ERROR 11:29:35 worker 16518 140021590959936 OperationalError: SSL error: decryption failed or bad record mac
Traceback (most recent call last):
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/rq/worker.py", line 568, in perform_job
rv = job.perform()
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/rq/job.py", line 495, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/tank/code/uitintranet/intranet/tasks.py", line 131, in backup_router
router = Router.objects.get(pk=router_pk)
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/models/query.py", line 328, in get
num = len(clone)
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/models/query.py", line 144, in __len__
self._fetch_all()
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/models/query.py", line 965, in _fetch_all
self._result_cache = list(self.iterator())
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/models/query.py", line 238, in iterator
results = compiler.execute_sql()
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
cursor.execute(sql, params)
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
OperationalError: SSL error: decryption failed or bad record mac
I checked, and updated rq from 0.5.4 to 0.5.5 and the error continues. If I run a command from my Django shell_plus without ‘.delay()’, it runs fine. If I run a command with ‘.delay()’ or I run a command using the scheduler, I get the error above.
I noticed a post on StackOverflow that basically says ‘close the DB connection at the beginning of each job’. (http://stackoverflow.com/questions/17523912/django-python-rq-databaseerror-ssl-error-decryption-failed-or-bad-record-mac)
I tested with one of my jobs, and it does fix the problem. But I’m worried about possible side effects, and having to add a few lines of code to hundreds of job definitions.
Issue Analytics
- State:
- Created 8 years ago
- Comments:16
Top Related StackOverflow Question
I totally misread celery/celery#634. It is definitely an SSL issue. But everything else django-related works fine.
manage.py runserverandmanage.py shell_pluscan interact with the DB without problems.When I specifically force SSL to be disabled in Django (and it’s optional in Postgres)
Everything works fine.
When I change ‘sslmode’ to ‘require’, Django operates without any problems and the connection is encrypted, but the workers start bombing.
A packet capture shows Postgres throwing a TCP reset and closing the connection.
Yes, adding
--worker-class rq.SimpleWorkerstops the database errors.