Hello, reader!

My name is Eugene Lazutkin.

I'm a software developer based in the Dallas-Fort Worth metroplex. Lazutkin.com is my professional blog, which contains short writeups and presentations regarding modern web applications. All articles here are written by myself, unless stated otherwise.

Django and MySQLdb worries

I am totally at loss. I am getting weird errors like this:

OperationalError: (2013, 'Lost connection to MySQL server during query')

They are pretty much random but fairly frequent. Apparently it may be caused by different MySQL timeouts, which I cannot control. It seems that in order to combat those you have to call connection.ping() periodically to reconnect. I added them to Django’s MySQL handler and … now I am getting these errors during execution of connection.ping()! Bizarre!

I cannot believe that I am the only one with this problem. But googling did find anything useful. Yes, I found a bunch of people complaining about it. No, there are no solutions posted. Am I the only one, who uses MySQLdb (indirectly from Django) from FastCGI process?

On the other hand all symptoms listed in the previous paragraph point to alternative conclusion: this problem is so simple and so stupid that people don’t bother to explain how to fix it. Hmm, is this really a case?

Update: Apparently this problem is widespread. Just take a look at Ruby On Rails ticket: http://dev.rubyonrails.com/ticket/428. It was opened in January 2005 but they couldn’t localize it and fix it.

Unbelievable! We are talking about FastCGI, which is widely used, and MySQL, which is widely used. Ruby or not, this problem should be solved by now. Are there FastCGI apps, which use MySQL?

Python and Ruby communities were around for many years but this simple problem is not solved yet.