[Twisted-Python] 2006, 'MySQL server has gone away'

Werner Thie wthie at thiengineering.ch
Thu Sep 20 05:39:58 MDT 2007


Hi all

While using mySQL V 5.0.33 and MySQL-python-1.2.2 with twisted/adbapi 
with the following connection params

DB_DRIVER = "MySQLdb"
DB_ARGS = {
     'host': 'xxx.xxx.xxx.xxx',
     'db': 'db',
     'user': 'dbuser',
     'passwd': 'dbpasswd'
     }

I noticed (2006, 'MySQL server has gone away') errors, which seem to be 
not recoverable from an adbapi standpoint.

Further analysis and reading the mySQL manual showed, that the mySQL 
server in versions > 5 seems to close open connections after (default) 8 
hours. The reconnect feature of the db is disabled by default and there 
is no parameter to preset it via MySQL-python.

Further digging brought up this link

http://sourceforge.net/tracker/index.php?func=detail&aid=1483074&group_id=22307&atid=374934

which patches the (also 1.2.2) version such, that a reconnect keyword is 
introduced in the DB_ARGS.

Questions:
- are there any adverse effects in applying this patch and setting 
reconnect: 1 in DB_ARGS?

- is there a better, safer way to avoid this nasty error?

Thxs, Werner




More information about the Twisted-Python mailing list