Google Groups Home
Help | Sign in
mysql connection timeout woes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Andrew Kuklewicz  
View profile
 More options Feb 26 2007, 12:38 pm
From: "Andrew Kuklewicz" <kooks...@gmail.com>
Date: Mon, 26 Feb 2007 17:38:53 -0000
Local: Mon, Feb 26 2007 12:38 pm
Subject: mysql connection timeout woes
Hey folks,

After long periods of inactivity (>~8 hours) that my a13g based app
often has overnight on weekends, I am noticing db timout errors from
mysql of the "Mysql::Error: MySQL server has gone away" variety.

Looking around a bit, I got a clue from the mogrel docs to solve this
using:

    ActiveRecord::Base.verification_timeout = 14400

But this timeout value is really only used by the
'ActiveRecord::Base.verify_active_connections!', which gets called in
rails from the following sequence:

    Dispatcher::dispatch -> prepare_application ->
ActiveRecord::Base.verify_active_connections!

So setting verification_timeout value does nothing on its own, and
since the poller in a13g does not call the verify_active_connections!,
setting this value would do nothing.

So my proposed solution (I am testing this now) is to add the
verify_active_connections call to the
ActiveMessaging::Gateway.dispatch method to do the same thing Rails
does - make sure this connection is good before sending it off to be
processed.

Anyone else seeing this problem, or have a better idea for a solution?

- Andrew


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Strachan  
View profile
 More options Feb 26 2007, 12:49 pm
From: "James Strachan" <james.strac...@gmail.com>
Date: Mon, 26 Feb 2007 17:49:13 +0000
Local: Mon, Feb 26 2007 12:49 pm
Subject: Re: mysql connection timeout woes

FWIW I did a hack in the mysql connection code to enable the
auto-reconnection property in the mysql driver - patch applied. Though
I never explicitly tested that it really did actually fix the issue
:). Not sure if there's a better approach though.

On 2/26/07, Andrew  Kuklewicz <kooks...@gmail.com> wrote:

--

James
-------
http://radio.weblogs.com/0112098/

[ patch.txt ]
Index: activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
===================================================================
--- activerecord/lib/active_record/connection_adapters/mysql_adapter.rb (revision 5909)
+++ activerecord/lib/active_record/connection_adapters/mysql_adapter.rb (working copy)
@@ -79,6 +79,12 @@
       mysql = Mysql.init
       mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslkey]

+      # lets default the auto reconnect option to true unless its specified in the configuration
+      # as it seems many people hit the mysql connections being timed out issue
+      value = config[:reconnect]
+      value = true if value.nil?
+      mysql.reconnect = value
+      
       ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket], config)
     end
   end


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google