We were continually having a problem on our production test server where we would get random 500 errors. The underlying error was that "MySQL server has gone away", and we searched around forever online trying to find a solution. Finally we did. I figured that I'd post here so that others could benefit.
Basically, the Python mysql library is missing an interface with the C library's MYSQL_OPT_RECONNECT flag which instructs the client to reconnect with the mysql server if the connection is lost or refused for some reason (which I guess can happen frequently on a busy server.) Thus, connections get dropped and you get 500 errors. Luckily, there's a patch that a user submitted to the mysqldb sourceforge project. Here's what to do: 1. First, go and download the patch from this location: http://sourceforge.net/tracker/index.php?func=detail&aid=1483074&group_id=22307&atid=374934 2. Get the correct version of MySQLdb to apply the patch to: svn co https://svn.sourceforge.net/svnroot/mysql-python/tags/MySQLdb-1.2.1_p2 mysqldb-patched 3. Go into the mysqldb-patched/MySQLdb/ directory and apply the patch to the install: patch < mysql-patch 4. Build the patched library python setup.py build (If you have errors here, make sure you have all the dev packages you need. Likely missing candidates are python-dev and libmysqlclient15-dev) 5. Install the patched library python setup.py install 6. Remove the bogus sets.py, sets.pyc, sets.pyo files. (For some reason, this version of mysqldb has files that override the default sets library. Just delete them all from your python site-packages/MySQLdb/ directory.) 7. Try importing MySQLdb (It should work now.) 8. Edit your SQLObject file: (In your SQLObject folder in site-packages, edit the mysql/mysqlconnection.py file and add reconnect=1 to the arguments passed to the self.module.connect function in MySQLConnection.makeConnection.) Now you should have no more "mysql has gone away" errors. (If that was your problem.) Anybody else ever have to do this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss -~----------~----~----~----~------~----~------~--~---
