OperationalError: (2006, 'MySQL server has gone away')
See original GitHub issueWhen ever i restart my MySql celeryd and celerycam throw OperationalError: (2006, ‘MySQL server has gone away’) .
Traceback (most recent call last):
File "/home/webapp/webapp/../vendor/djcelery/schedulers.py", line 204, in sync
with commit_on_success():
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/home/webapp/webapp/../vendor/djcelery/db.py", line 56, in commit_on_success
with transaction.atomic(using):
File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py", line 280, in __enter__
connection.set_autocommit(False)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 333, in set_autocommit
self._set_autocommit(autocommit)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 460, in _set_autocommit
self.connection.autocommit(autocommit)
OperationalError: (2006, 'MySQL server has gone away')
Is it a bug ?
Issue Analytics
- State:
- Created 9 years ago
- Comments:23 (5 by maintainers)
Top Results From Across the Web
MySQL error 2006: mysql server has gone away
This generally indicates MySQL server connectivity issues or timeouts. Can generally be solved by changing wait_timeout and max_allowed_packet ...
Read more >"MySQL server has gone away" error - Solution(s)
The MySQL server has gone away error, which means that the MySQL server (mysqld) timed out and closed the connection. By default, MySQL...
Read more >How do I fix the error "Mysql Server has gone away"? FAQ
The MySQL server has gone away (error 2006) has two main causes and solutions: Server timed out and closed the connection. To fix,...
Read more >B.3.2.7 MySQL server has gone away
The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection. In...
Read more >python - Error 2006: MySQL server has gone away
I looked in the uWSGI log, and found the following: sqlalchemy.exc.OperationalError: (OperationalError) (2006, 'MySQL server has gone away') ' ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
👍
I can update, that this is not an issue of
django-celery
project. I encounter this with Django 1.8.13 and Celery 3.1.23, not usingdjango-celery
at all. To get rid of the error, i force ainside my Celery job before starting a possibly-long-running process. Django then re-opens the connection on the nearest database request. Another workaround can be implementing a decorator, that would attempt to execute a function and catch the “MySQL server has gone away” exception. If caught, then close the connection and try again. I use this approach to re-establish lost sftp connections, and i think this should work for reconnecting to MySQL.