Hi all,
I am using GeoDjango and I have a django-admin command that does some route calculations for approximately 24 hours and then saves the results to a MySQL database. Unfortunately the database connection times out after 8 hours resulting in: django.db.utils.OperationalError: (2006, 'MySQL server has gone away'). I check in the mysql logs that this is indeed a timeout error. It seems to be the case that django is maintaining a persistent connection even when I set CONN_MAX_AGE to 60 seconds (although perhaps this parameter applies only to requests). Is there a solution to this issue without simply increasing the timeout in MySQL?
So far I have tried closing the connections manually using:
from django.db import connections
connections.close_all()
I also tried simply catching the exception and retrying the write to the database (it's stated that Django automatically reopens connections on new queries here:
https://docs.djangoproject.com/en/1.10/ref/databases/#connection-management), but the same error occurs.
I am using Django 1.10 and Python 2.7.12 on Linux, if that helps.
Any help is greatly appreciated.
Thanks in advance,
Charanpal