Forum: Ruby on Rails Rails 2.2.2 - Mysql::Error: MySQL server has gone away

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
De359ced43a7d50dfe8fd2c6d4d8178f?d=identicon&s=25 Adeel Ahmad (a2ahmad)
on 2009-03-03 03:56
My app consists of receiving emails with image attachments from its
users so I have been employing the MMS2R gem and Fetcher. Every 60
seconds the app goes to the email server to fetch emails.

Under Rails 2.1.1 things worked fine - when I received an email, the
email was fetched, parsed and saved to the database.

However I needed to upgrade to Rails 2.2.2 for unrelated reasons and now
I get the following error in my log when the app tries to save to the
database. Emailpic is just the model in the database.

"Emailpic Columns (0.0ms)   Mysql::Error: MySQL server has gone away:
SHOW FIELDS FROM `emailpics`"

Does anyone know what changed between 2.1.1 and 2.2.2 to cause this to
happen?
De359ced43a7d50dfe8fd2c6d4d8178f?d=identicon&s=25 Adeel Ahmad (a2ahmad)
on 2009-03-03 05:32
This was solved by the fine guys at Engine Yard.
I added the following lines to my environmemnt.rb:

ActiveRecord::Base.allow_concurrency = true
ActiveRecord::Base.verification_timeout = 10

And just before I do a fetch I have this line:

Emailpic.verify_active_connections!
3b665e30662d48a0da4cd78569b396df?d=identicon&s=25 Tung Nguyen (tongueroo)
on 2009-03-09 05:57
Adeel,

This worked for you with activerecord 2.2.2 ?

The Engineyard guys suggested the same thing to me, but we're getting
this deprecation working..

DEPRECATION WARNING: ActiveRecord::Base.verification_timeout= has been
deprecated and no longer has any effect. Please remove all references to
verification_timeout=.. (called from verification_timeout= at
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:106)


Tung

Adeel Ahmad wrote:
> This was solved by the fine guys at Engine Yard.
> I added the following lines to my environmemnt.rb:
>
> ActiveRecord::Base.allow_concurrency = true
> ActiveRecord::Base.verification_timeout = 10
>
> And just before I do a fetch I have this line:
>
> Emailpic.verify_active_connections!
3b665e30662d48a0da4cd78569b396df?d=identicon&s=25 Tung Nguyen (tongueroo)
on 2009-03-09 06:24
ic, youre doing a

Emailpic.verify_active_connections!

So, thats what is probably reestablishing the connection....
3b665e30662d48a0da4cd78569b396df?d=identicon&s=25 Tung Nguyen (tongueroo)
on 2009-03-09 06:25
I just wonder if there's a more automated way of doing this, instead of
manually have to check the connection every time we do a mysql query...
Bfccdb1c41c334fec20e5ede3a7ccfcc?d=identicon&s=25 Andrew Roth (andrewroth)
on 2009-03-21 22:21
(Received via mailing list)
I'm getting these MySQL server has gone away on SHOW FIELDS too.  I've
spent a fair bit of effort trying to figure out what's going on, with
no success.  All we've determined is it seems to have a higher chance
of happening after some idle time.  I can usually make it happen by
hitting an ajax page with many requests at once (just spamming the
ajax).  Any ideas welcome.

On Mar 2, 10:56 pm, Adeel Ahmad <rails-mailing-l...@andreas-s.net>
Bfccdb1c41c334fec20e5ede3a7ccfcc?d=identicon&s=25 Andrew Roth (andrewroth)
on 2009-03-26 02:32
(Received via mailing list)
I've had some success with the mysql_retry_lost_connection gem.
This topic is locked and can not be replied to.