Rails 2.2.2 - Mysql::Error: MySQL server has gone away

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?

This was solved by the fine guys at Engine Y…
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!

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 A. wrote:

This was solved by the fine guys at Engine Y…
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!

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…

ic, youre doing a

Emailpic.verify_active_connections!

So, thats what is probably reestablishing the connection…

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 A. [email protected]

I’ve had some success with the mysql_retry_lost_connection gem.

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