"MySQL server has gone away" with Apache 2.2 + Mongrel clust

Hi

I just setup a server (Apache 2.2, mod_proxy_balancer, mongrel_cluster)
with
2 Rails applications according to this excellent Post:
http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you

Everythings works great, but after a long inactive period (say one
night),
the first 3 connections allways get an Error 500

Excerpt from production.log:

Rendering authentication/login
Completed in 0.00301 (332 reqs/sec) | Rendering: 0.00279 (92%) | DB:
0.00000(0%) | 200 OK
[ http://myapp/authentication/login ]
Mysql::Error: MySQL server has gone away: SELECT * FROM sessions WHERE
(session_id = ‘875b6a6dff4de7e8bb2f7709cf9c31db’) LIMIT 1

Note: the mongrel cluster is configured to have 3 mongrel processes. Is
this a clue why only the first 3 connections allways get the error ?

Thanks for your input.

what version of MySQL are you running?

ed

On 10/10/06, Eric R. [email protected] wrote:

Note: the mongrel cluster is configured to have 3 mongrel processes. Is
this a clue why only the first 3 connections allways get the error ?

Thanks for your input.


Ed Hickey
Developer
Litmus Media
816-533-0409
[email protected]
A Member of Think Partnership, Inc
www.ThinkPartnership.com
Amex ticker symbol: THK

Everythings works great, but after a long inactive period (say one night),
the first 3 connections allways get an Error 500

Did you “gem install mysql” the latest version of the mysql gem? That
always seems to clear up my mysql issues.

On Debian Sarge:
dpkg --list | grep mysql
ii libdbd-mysql-p 2.9006-1 A Perl5 database interface to the
MySQL data
ii libmysqlclient 3.23.56-3 LGPL-licensed client library for
MySQL datab
ii libmysqlclient 3.23.56-3 LGPL-licensed client development
files for M
ii libmysqlclient 4.0.24-10sarge mysql database client library
ii libmysqlclient 4.1.11a-4sarge mysql database client library
ii mysql-client-4 4.1.11a-4sarge mysql database client binaries
ii mysql-common-4 4.1.11a-4sarge mysql database common files (e.g.
/etc/mysql
ii mysql-server-4 4.1.11a-4sarge mysql database server binaries

I dont know what the latest mysql gem version is.
However, gem list --local shows mysql (2.7)

MySQL times out connections after a period of inactivity. (see
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html) I think the
period defaults to 8 hours. You can see the same behavior if you open a
connection using the “mysql” command-line client, and leave it inactive
for a long time. The next query will fail at first (but the client
automatically reconnects).

Apparently, there are system variables (wait_timeout and
interactive_timeout) that you can set to increase the timeout. I’ve
never had to do this from Rails, though, so I’m not sure of the
procedure. In our case, we have a monitoring script that hits our site
and database periodically to make sure it’s all still up, and that has
the side effect of keeping the mysql connections alive.

Daniel A.
Zoodango.com

Eric R. wrote:

Everythings works great, but after a long inactive period (say one
night),
the first 3 connections allways get an Error 500

Excerpt from production.log:

Rendering authentication/login
Completed in 0.00301 (332 reqs/sec) | Rendering: 0.00279 (92%) | DB:
0.00000(0%) | 200 OK
[ http://myapp/authentication/login ]
Mysql::Error: MySQL server has gone away: SELECT * FROM sessions WHERE
(session_id = ‘875b6a6dff4de7e8bb2f7709cf9c31db’) LIMIT 1

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs