views:

1173

answers:

4
A: 

I got this error after a script I wrote went AWOL and inserted 10000 rows into a table simultaneously. Seemed like a failsafe to me - not sure if that relates to your problem...

Andrew G. Johnson
A: 

You might want to check MySQL's timeout variables:

show variables like '%timeout%';

You're probably interested in waittimeout (less likely but possible: interactivetimeout). On Debian and Ubuntu, the defaults are 28800 (MySQL kills connections after 8 hours), but maybe the default for your platform is different or whoever administrates the server has configured things differently.

AFAICT, pool_recycle doesn't actually keep the connections alive, it expires them on its own before MySQL kills them. I'm not familiar with pylons, but if causing the connections to intermittently do a "SELECT 1;" is an option, that will keep them alive at the cost of basically no server load and minimal network traffic. One final thought: are you somehow managing to use a connection that pylons thinks it has expired?

Jon Bright
A: 

@Jon Bright - I can't say for certain; I don't know the internals of Pylons well enough yet. I haven't had a chance to poke through the documentation yet either (busy busy). I don't think the SELECT 1; thing is an option though, seems kind of kludgey too :).

swilliams
+3  A: 

I think I fixed it. It's turns out I had a simple config error. My ini file read:

sqlalchemy.default.url = [connection string here]
sqlalchemy.pool_recycle = 1800

The problem is that my environment.py file declared that the engine would only map keys with the prefix: sqlalchemy.default so pool_recycle was ignored.

The solution is to simply change the second line in the ini to:

sqlalchemy.default.pool_recycle = 1800
swilliams
Just recently saw some traffic on this post. It should be noted that this issue was relating to Pylons 0.9.6. This should be taken care of in Pylons 0.9.7, and the 'sqlalchemy.default' property goes away in favor of just plain 'sqlalchemy'
swilliams