Dear django'ers:
Configuration: django 1.6.5, mysql connector/python 1.2.2, mysql server 5.5.37, apache worker 2.2.22 with mod_fastcgi, and python 3.3.5 on an otherwise stock and up-to-date ubuntu 12.04 setup.
Problem: django is not reconnecting to the database after a mysql server restart. From what I read it should connect to the database *on each request* if CONN_MAX_AGE is 0. Access works properly in normal operation but after bouncing the mysql server the database access fails with an exception of "MySQL Connection not available" and an http server restart is required. After that access works properly again.
I've tested restarting mysql server with all of the above except django i.e. with just a simple wsgi script and no http server restart is required so this doesn't seem to be a problem with the mysql connector/python adapter itself but between django and the adapter i.e. something in django/db/backends/__init__.py or mysql/connector/django/base.py. The ensure_connection() method in backends/__init.py__ just doesn't seem to be doing what it should.
Am I misinterpreting what I read about reconnecting?
Last part of traceback:
File "/usr/local/lib/python3.3/dist-packages/django/db/models/sql/compiler.py" in results_iter
713. for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python3.3/dist-packages/django/db/models/sql/compiler.py" in execute_sql
785. cursor = self.connection.cursor()
File "/usr/local/lib/python3.3/dist-packages/django/db/backends/__init__.py" in cursor
160. cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/lib/python3.3/dist-packages/mysql/connector/django/base.py" in _cursor
554. return super(DatabaseWrapper, self)._cursor()
File "/usr/local/lib/python3.3/dist-packages/django/db/backends/__init__.py" in _cursor
134. return self.create_cursor()
File "/usr/local/lib/python3.3/dist-packages/django/db/utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python3.3/dist-packages/django/utils/six.py" in reraise
549. raise value.with_traceback(tb)
File "/usr/local/lib/python3.3/dist-packages/django/db/backends/__init__.py" in _cursor
134. return self.create_cursor()
File "/usr/local/lib/python3.3/dist-packages/mysql/connector/django/base.py" in create_cursor
539. cursor = self.connection.cursor()
File "/usr/local/lib/python3.3/dist-packages/mysql/connector/connection.py" in cursor
1328. raise errors.OperationalError("MySQL Connection not available.")
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment