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.") -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53AAC8FB.5010607%40gmail.com. For more options, visit https://groups.google.com/d/optout. |