Ruby on Rails Errno :: EPIPE Разбитая труба - PullRequest
7 голосов
/ 04 декабря 2010

Я знаю, что многие люди публикуют это в Интернете, но мне не удалось найти решение.

Я получаю сообщение об ошибке:8 часов.Я читал об этом, возможно, в связи с драйвером ruby-mysql, но не нашел решения.Вот полный след.Я бегу ruby ​​на сервере рельсов на apache с пассажиром и MySQL.Спасибо за помощь !!!

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.0) lib/active_record/connection_adapters/mysql_adapter.rb:238:in `active?'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract_adapter.rb:148:in `verify!'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:250:in `checkout_and_verify'
activesupport (3.0.0) lib/active_support/callbacks.rb:413:in `_run_checkout_callbacks'
activesupport (3.0.0) lib/active_support/callbacks.rb:93:in `send'
activesupport (3.0.0) lib/active_support/callbacks.rb:93:in `run_callbacks'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:249:in `checkout_and_verify'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_existing_connection'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:192:in `checkout'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `loop'
activerecord (3.0.0) 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.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:189:in `checkout'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in `connection'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:318:in `retrieve_connection'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
activerecord (3.0.0) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.0) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `call'
actionpack (3.0.0) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
activesupport (3.0.0) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.0) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.0) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.0) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call'
railties (3.0.0) 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.0) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.0) lib/rails/application.rb:168:in `call'
railties (3.0.0) lib/rails/application.rb:77:in `send'
railties (3.0.0) lib/rails/application.rb:77:in `method_missing'
passenger (3.0.0) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.0) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
passenger (3.0.0) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
passenger (3.0.0) lib/phusion_passenger/utils.rb:479:in `safe_fork'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.0) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
passenger (3.0.0) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
passenger (3.0.0) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
passenger (3.0.0) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
passenger (3.0.0) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.0) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
/usr/share/phusion-passenger/helper-scripts/passenger-spawn-server:99</blink>

Ответы [ 3 ]

5 голосов
/ 10 августа 2011

Если у вас нет особых причин использовать ruby-mysql, удалите его, установите mysql gem по умолчанию

gem install mysql2

и используйте его в своем Gemfile:

gem "mysql2"

По словам автора блога, упомянутого Богданом Похорильцем, именно так и была решена проблема.

1 голос
/ 31 декабря 2010

Я добавил следующее в ... / app / controllers / application_controller.rb

before_filter :verify_connection

def verify_connection
  Product.verify_active_connections!
end

(Продукт - одна из моих моделей - любая должна работать), и эта проблема исчезла.

0 голосов
/ 10 августа 2011

У меня была эта ошибка, когда я работал с обходным приемом push-уведомлений от Apple http://gaveen.owain.org/2008/04/errnoepipe-broken-pipe-mysql-error-in.html решена проблема

Создайте спящий поток, который будет периодически использовать соединение с БД. Например:

Thread.new do
 loop do
   sleep(30*60)
   logger.fatal("ActiveRecord::Base.verify_active_connections!")
   ActiveRecord::Base.verify_active_connections!
   ActiveRecord::Base.connection.select_value('select 1')
 end
end
...