Thanks, Ben! That's exactly what I needed. Once I put that in each worker
pinged the database every five minutes, and the connection seems stable
now. It seems that the keepalives were only going as far as our load
balancer, and the load balancer was killing the connection to the database.
On Friday, February 14, 2014 8:28:08 AM UTC-5, Richard Sugg wrote:
>
> But each worker has it's own database connection - will this refresh the
> connection for each worker or just the worker that happens to handle the
> ping?
>
> On Thursday, February 13, 2014 9:45:55 PM UTC-5, Ben van Staveren wrote:
>>
>> On 02/14/2014 09:21 AM, Richard Sugg wrote:
>> > I think the reason I keep getting "mysql server has gone away" is
>> because
>> > I'm connecting to a database that has a firewall in front. The fw
>> > terminates idle sessions after 30 minutes, so I think some of the
>> database
>> > connections are getting closed while the workers are still active.
>> >
>> > This would explain the random failures -- if I have five workers and
>> not
>> > much traffic, perhaps only one or two workers do the work. The others
>> would
>> > have their database connections closed while they are still active.
>> >
>> > I can't change the firewall so what can I do to my application to
>> mitigate
>> > this?
>> >
>> In your startup - or at an appropriate location...
>>
>> Mojo::IOLoop->recurring(300 => sub {
>> $self->your_dbh->ping();
>> });
>>
>> Something along those lines
>>
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.