samedi 29 novembre 2014

python - Django | OperationalError : Connexion MySQL indisponible, disparaît sur le rechargement de la page, ce qui est erroné ? -Débordement de pile


I am sometimes getting the following error in Django, which disappears on page reload, I don't know how to reproduce it. I tried to set wait_timeout to 12 hours in my.cnf, but the error appeared again on mysqld restart, though did not when I restarted mysqld again, very wierd for me.


Traceback (most recent call last):
File ".../python3.4/site-packages/django/db/backends/__init__.py", line 131, in _cursor
return self.create_cursor()
File ".../python3.4/site-packages/mysql/connector/django/base.py", line 536, in create_cursor
cursor = self.connection.cursor()
File ".../python3.4/site-packages/mysql/connector/connection.py", line 1231, in cursor
raise errors.OperationalError("MySQL Connection not available.")
mysql.connector.errors.OperationalError: MySQL Connection not available.



Do you use django 1.6? Maybe there are no requests for particular process for 12 hours? Seems like connection was broken by timeout and reopen in next request. Try to set CONN_MAX_AGE=3600 in database section of django settings file. If this value less than wait_timeout in mysql config you prevent connection timeout error.


https://docs.djangoproject.com/en/1.6/ref/settings/#conn-max-age



I am sometimes getting the following error in Django, which disappears on page reload, I don't know how to reproduce it. I tried to set wait_timeout to 12 hours in my.cnf, but the error appeared again on mysqld restart, though did not when I restarted mysqld again, very wierd for me.


Traceback (most recent call last):
File ".../python3.4/site-packages/django/db/backends/__init__.py", line 131, in _cursor
return self.create_cursor()
File ".../python3.4/site-packages/mysql/connector/django/base.py", line 536, in create_cursor
cursor = self.connection.cursor()
File ".../python3.4/site-packages/mysql/connector/connection.py", line 1231, in cursor
raise errors.OperationalError("MySQL Connection not available.")
mysql.connector.errors.OperationalError: MySQL Connection not available.


Do you use django 1.6? Maybe there are no requests for particular process for 12 hours? Seems like connection was broken by timeout and reopen in next request. Try to set CONN_MAX_AGE=3600 in database section of django settings file. If this value less than wait_timeout in mysql config you prevent connection timeout error.


https://docs.djangoproject.com/en/1.6/ref/settings/#conn-max-age


0 commentaires:

Enregistrer un commentaire