Reputation: 3627
This is the environment:
AWS Aurora database compatible with MySql.
Django 2.0.3 (Python 3.6)
Pip-Mysql dependencies: django-mysql==2.2.2, mysqlclient==1.3.12.
Master-Slave database configuration.
It seems that django or mysql engine always fails on certain queries resulting in this specific error:
Traceback (most recent call last): File "/home/ubuntu/ivs/vpython/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 158, in get rel_obj = self.field.get_cached_value(instance) File "/home/ubuntu/ivs/vpython/lib/python3.6/site-packages/django/db/models/fields/mixins.py", line 13, in get_cached_value return instance._state.fields_cache[cache_name] KeyError: 'assigned_to'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/ubuntu/ivs/vpython/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/home/ubuntu/ivs/vpython/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute return self.cursor.execute(query, args) File "/home/ubuntu/ivs/vpython/lib/python3.6/site-packages/MySQLdb/cursors.py", line 253, in execute self._warning_check() File "/home/ubuntu/ivs/vpython/lib/python3.6/site-packages/MySQLdb/cursors.py", line 148, in _warning_check warnings = db.show_warnings() File "/home/ubuntu/ivs/vpython/lib/python3.6/site-packages/MySQLdb/connections.py", line 381, in show_warnings self.query("SHOW WARNINGS") File "/home/ubuntu/ivs/vpython/lib/python3.6/site-packages/MySQLdb/connections.py", line 277, in query _mysql.connection.query(self, query) _mysql_exceptions.OperationalError: (2013, 'Lost connection to MySQL server during query')
Yes, one of my models have "assigend_to" field which is a foreign key. But why does it fail with a KeyError?
Did anyone have any similar KeyErrors and MySql lost connections as a result?
Upvotes: 1
Views: 983
Reputation: 3627
Wow, what actually was happening is this:
Upvotes: 0
Reputation: 1847
In official MySQL definition, there is a specific page about this error. As can be seen from here in detail, here are what you should try:
net_read_timeout
to 60 seconds etc.Upvotes: 1