# Lost connection to MySQL server during query: SHOW FIELDS FR

**URL:** <https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query-show-fields-fr/77584>\
**Category:** Rails\
**Created:** [November 28, 2006, 11:10pm UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query-show-fields-fr/77584 "2006-11-28T23:10:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![minka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b38774/32.png) [@minka](https://www.ruby-forum.com/u/minka)\
**Post date:** [November 28, 2006, 11:10pm UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query-show-fields-fr/77584/1 "2006-11-28T23:10:58Z")

</div>

I am getting an intermittent error, the one above. I have not gone into  
production, i am still in development. I seem to lose connection to the  
MySQL server. If I do a refresh it comes back and all is fine.

I have not been able to duplicate this. It simply occurs perhaps 1 out  
of ten times. Is this a characteristic of the development mode? I am  
using WEBrick.  
thanks, minka.

Here is the error:  
ActiveRecord::StatementInvalid in ProductsController#save\_order  
Mysql::Error: Lost connection to MySQL server during query: SHOW FIELDS  
FROM orders

Here is a partial trace:  
RAILS\_ROOT: script/…/config/…  
Application Trace | Framework Trace | Full Trace

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/connection\_adapters/abstract\_adapter.rb:120:in  
`log' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/mysql_adapter.rb:184:in`execute’  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/connection\_adapters/mysql\_adapter.rb:292:in  
`columns' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:696:in`columns’  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/base.rb:1969:in  
`attributes_from_column_definition' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1351:in`initialize\_without\_callbacks’  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/callbacks.rb:236:in  
`initialize' app/controllers/products_controller.rb:87:in`save\_order’  
-e:4

---

<div class="post-metadata">

**Author:** ![minka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b38774/32.png) [@minka](https://www.ruby-forum.com/u/minka)\
**Post date:** [November 28, 2006, 11:33pm UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query-show-fields-fr/77584/2 "2006-11-28T23:33:01Z")

</div>

On Nov 28, 2006, at 4:08 PM, minka wrote:

> thanks, minka.
> 
> Here is the error:  
> ActiveRecord::StatementInvalid in ProductsController#save\_order  
> Mysql::Error: Lost connection to MySQL server during query: SHOW  
> FIELDS  
> FROM orders

It might be related to using the ruby mysql bindings instead of the  
native C bindings for your platform. Install the ‘mysql’ gem. It will  
build a native code extension callable from ruby which eliminates  
most mysql connection drops.

After installing the gem, make sure it is active by doing the  
following (swiped this from a post earlier this week!):

cremes$ irb  
irb(main):001:0\> require ‘rubygems’  
=\> true  
irb(main):002:0\> require ‘mysql’  
=\> false  
irb(main):003:0\> puts Mysql::VERSION  
20700  
=\> nil

cr

---

<div class="post-metadata">

**Author:** ![minka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b38774/32.png) [@minka](https://www.ruby-forum.com/u/minka)\
**Post date:** [November 29, 2006, 6:32am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query-show-fields-fr/77584/3 "2006-11-29T06:32:45Z")

</div>

Chuck R. wrote:

> On Nov 28, 2006, at 4:08 PM, minka wrote:
> 
> > thanks, minka.
> > 
> > Here is the error:  
> > ActiveRecord::StatementInvalid in ProductsController#save\_order  
> > Mysql::Error: Lost connection to MySQL server during query: SHOW  
> > FIELDS  
> > FROM orders

Try this.

[http://www.afeared.org/?comment,343](http://www.afeared.org/?comment,343)

It fixed the problem for me.

---

<div class="post-metadata">

**Author:** ![minka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b38774/32.png) [@minka](https://www.ruby-forum.com/u/minka)\
**Post date:** [November 29, 2006, 11:22am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query-show-fields-fr/77584/4 "2006-11-29T11:22:39Z")

</div>

If all else fails, try pre-loading your models if you are storing whole  
objects in the session. I was having what appeared to be intermittent  
db issues but the problem was the serialization of objects to the  
session.

class ApplicationController \< ActionController::Base  
model :order, :member, :cart  
end

Good luck,  
Chad
