我知道有很多人在网上发帖,但我找不到解决方案。
我的网站未被访问后,我收到了Errno :: EPIPE> 6-8小时。我读到它可能与ruby-mysql驱动程序有关,但还没有找到解决方案。这是完整的痕迹。我在带有乘客和mysql的apache上的rails服务器上运行ruby。谢谢你的帮助!!!
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>
答案 0 :(得分:5)
除非您使用ruby-mysql有特殊原因, 删除它,安装'默认'mysql gem
gem install mysql2
并在你的Gemfile中使用它:
gem "mysql2"
根据Bohdan Pohorilets提到的博客作者的说法,问题是如何解决的。
答案 1 :(得分:1)
我将以下内容添加到... / app / controllers / application_controller.rb
before_filter :verify_connection
def verify_connection
Product.verify_active_connections!
end
(产品是我的模特之一 - 任何人应该工作),这个问题就消失了。
答案 2 :(得分:0)
我正在使用来自http://gaveen.owain.org/2008/04/errnoepipe-broken-pipe-mysql-error-in.html解决问题
的Apple推送通知解决方法时遇到此错误创建一个可以定期使用DB连接的睡眠线程 例如:
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