tmtm / ruby-mysql

MySQL connector for Ruby. pure Ruby version.
MIT License
144 stars 34 forks source link

Errno::EPIPE (Broken pipe) #5

Open TeuF opened 13 years ago

TeuF commented 13 years ago

Hi,

I have some problem with ruby-mysql 2.9.3 After restarting the server everything works fine for 5 minutes, then I got the same error again.

Errno::EPIPE (Broken pipe):
  ruby-mysql (2.9.3) lib/mysql/protocol.rb:617:in `flush'
  ruby-mysql (2.9.3) lib/mysql/protocol.rb:617:in `write'
  /usr/lib/ruby/1.8/timeout.rb:53:in `timeout'
  ruby-mysql (2.9.3) lib/mysql/protocol.rb:616:in `write'
  ruby-mysql (2.9.3) lib/mysql/protocol.rb:640:in `simple_command'
  ruby-mysql (2.9.3) lib/mysql/protocol.rb:545:in `synchronize'
  ruby-mysql (2.9.3) lib/mysql/protocol.rb:638:in `simple_command'
  ruby-mysql (2.9.3) lib/mysql/protocol.rb:413:in `statistics_command'
  ruby-mysql (2.9.3) lib/mysql.rb:502:in `stat'
  activerecord (3.0.1) lib/active_record/connection_adapters/mysql_adapter.rb:238:in `active?'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract_adapter.rb:148:in `verify!'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:250:in `checkout_and_verify'
  activesupport (3.0.1) lib/active_support/callbacks.rb:413:in `_run_checkout_callbacks'
  activesupport (3.0.1) lib/active_support/callbacks.rb:93:in `send'
  activesupport (3.0.1) lib/active_support/callbacks.rb:93:in `run_callbacks'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:249:in `checkout_and_verify'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_existing_connection'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:192:in `checkout'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `loop'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `checkout'
  /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:189:in `checkout'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in `connection'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:318:in `retrieve_connection'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
  activerecord (3.0.1) lib/active_record/query_cache.rb:12:in `cache'
  activerecord (3.0.1) lib/active_record/query_cache.rb:31:in `call'
  activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `call'
  actionpack (3.0.1) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
  activesupport (3.0.1) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
  actionpack (3.0.1) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
  rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
  actionpack (3.0.1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
  actionpack (3.0.1) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call'
  railties (3.0.1) lib/rails/rack/logger.rb:13:in `call'
  rack (1.2.1) lib/rack/runtime.rb:17:in `call'
  rack (1.2.1) lib/rack/lock.rb:11:in `call'
  rack (1.2.1) lib/rack/lock.rb:11:in `synchronize'
  rack (1.2.1) lib/rack/lock.rb:11:in `call'
  actionpack (3.0.1) lib/action_dispatch/middleware/static.rb:30:in `call'
  railties (3.0.1) lib/rails/application.rb:168:in `call'
  railties (3.0.1) lib/rails/application.rb:77:in `send'
  railties (3.0.1) lib/rails/application.rb:77:in `method_missing'
  thin (1.2.7) lib/thin/connection.rb:76:in `pre_process'
  thin (1.2.7) lib/thin/connection.rb:74:in `catch'
  thin (1.2.7) lib/thin/connection.rb:74:in `pre_process'
  thin (1.2.7) lib/thin/connection.rb:57:in `process'
  thin (1.2.7) lib/thin/connection.rb:42:in `receive_data'
  eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine'
  eventmachine (0.12.10) lib/eventmachine.rb:256:in `run'
  thin (1.2.7) lib/thin/backends/base.rb:57:in `start'
  thin (1.2.7) lib/thin/server.rb:156:in `start'
  thin (1.2.7) lib/thin/controllers/controller.rb:80:in `start'
  thin (1.2.7) lib/thin/runner.rb:177:in `send'
  thin (1.2.7) lib/thin/runner.rb:177:in `run_command'
  thin (1.2.7) lib/thin/runner.rb:143:in `run!'
  thin (1.2.7) bin/thin:6
  /usr/bin/thin:19:in `load'
  /usr/bin/thin:19

My bundle

$ bundle list
Gems included by the bundle:
  * RedCloth (4.2.3)
  * aasm (2.2.0 5d71530)
  * abstract (1.0.0)
  * actionmailer (3.0.1)
  * actionpack (3.0.1)
  * activemodel (3.0.1)
  * activerecord (3.0.1)
  * activeresource (3.0.1)
  * activesupport (3.0.1)
  * acts-as-taggable-on (2.0.6)
  * acts_as_commentable (3.0.0 247df98)
  * ajaxful_rating (3.0.0.beta3 81b563e)
  * arel (1.0.1)
  * authlogic (2.1.3 a087ad0)
  * authlogic-oauth (1.0.8 5416269)
  * babosa (0.2.0)
  * builder (2.1.2)
  * bundler (1.0.0)
  * cancan (1.4.0)
  * daemons (1.0.10)
  * date_validator (0.5.9)
  * delayed_job (2.1.0.pre b52361d)
  * erubis (2.6.6)
  * exception_notification (1.0.0 192a49a)
  * friendly_id (3.1.7)
  * gem_plugin (0.2.3)
  * geokit (1.5.0)
  * i18n (0.4.1)
  * json (1.4.6)
  * mail (2.2.7)
  * mime-types (1.16)
  * mongrel (1.2.0.pre2)
  * newrelic_rpm (2.13.2)
  * nokogiri (1.4.3.1)
  * oauth (0.4.3)
  * paperclip (2.3.4 ef7233d)
  * polyglot (0.3.1)
  * rack (1.2.1)
  * rack-mount (0.6.13)
  * rack-test (0.5.6)
  * rails (3.0.1)
  * rails3-jquery-autocomplete (0.4.0)
  * railties (3.0.1)
  * rake (0.8.7)
  * riddle (1.1.0)
  * ruby-graphviz (0.9.18)
  * ruby-mysql (2.9.3)
  * thinking-sphinx (2.0.0.rc2 108a1fc)
  * thor (0.14.3)
  * treetop (1.4.8)
  * twitter_oauth (0.4.3)
  * tzinfo (0.3.23)
  * will_paginate (3.0.pre3 b1a5bee)

What's wrong ? :S

Thx

cimm commented 13 years ago

Same problem here... as far as I can tell it has something to do with the database connection being closed when not accessed for x minutes. Didn't find a decent fix yet.

antiloopgmbh commented 13 years ago

Same here - any hints greatly appreciated! I should mention that i use Rails 3.0.1, ruby-mysql 2.9.3 and passenger-3.0.0. It seems that the problem only occurs with passenger-3.0.0. I switched my production servers back to passenger-2.2.15 and the problem disappeared.

JangoSteve commented 13 years ago

Same problem here, working with Rails 3.0.5, Passenger 3.0.5, and Nginx on Amazon EC2.

cimm commented 13 years ago

For those having problems with the MySQL gem and Rails 3, please have a look at the mysql2 gem at https://github.com/brianmario/mysql2, it's the new default MySQL driver. Head over to Yehuda's post for some more information: http://yehudakatz.com/2010/08/14/threads-in-ruby-enough-already/