2011-08-31 22 views
6

Ho un server di produzione (Nginx + Passenger). Quando ho cercando di ab -n 3 -c 3 myhost.ru/ da un altro computer ottengo questo registro degli errori nel mio nginx error.log:Errore connessioni concorrenti passeggeri

[ pid=21160 thr=139775297914624 file=ext/nginx/HelperAgent.cpp:584 time=2011-08-31 15:25:49.22 ]: Uncaught exception in PassengerServer client thread: 
    exception: Cannot read response from backend process: Connection reset by peer (104) 
    backtrace: 
    in 'void Client::forwardResponse(Passenger::SessionPtr&, Passenger::FileDescriptor&, const Passenger::AnalyticsLogPtr&)' (HelperAgent.cpp:330) 
    in 'void Client::handleRequest(Passenger::FileDescriptor&)' (HelperAgent.cpp:510) 
    in 'void Client::threadMain()' (HelperAgent.cpp:603) 

[ pid=21249 thr=15884760 file=utils.rb:176 time=2011-08-31 15:25:49.022 ]: *** Exception PGError in application (server closed the connection unexpectedly 
    This probably means the server terminated abnormally 
    before or while processing the request. 
) (process 21249, thread #<Thread:0x00000001e4c3b0>): 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `exec' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `block in clear_cache!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:275:in `each_value' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:275:in `clear_cache!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:303:in `disconnect!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:202:in `block in disconnect!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `each' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `disconnect!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:35:in `block in disconnect_with_synchronization!' 
    from /home/deployer/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:34:in `disconnect_with_synchronization!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `block in clear_all_connections!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `each_value' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `clear_all_connections!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `clear_all_connections!' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/utils.rb:398:in `before_handling_requests' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:204:in `start_request_handler' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:170:in `block in handle_spawn_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/utils.rb:479:in `safe_fork' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:180:in `start' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:128:in `start' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize' 
    from <internal:prelude>:10:in `synchronize' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/helper-scripts/passenger-spawn-server:99:in `<main>' 
2011/08/31 15:25:49 [error] 21197#0: *41173 upstream prematurely closed connection while reading response header from upstream, client: 78.47.253.164, server: yandex.ru, request: "GET/HTTP/1.0", upstream: "passenger:unix:/passenger_helper_server:", host: "yandex.ru" 
[ pid=21160 thr=139775298115328 file=ext/nginx/HelperAgent.cpp:584 time=2011-08-31 15:25:49.31 ]: Uncaught exception in PassengerServer client thread: 
    exception: Cannot read response from backend process: Connection reset by peer (104) 
    backtrace: 
    in 'void Client::forwardResponse(Passenger::SessionPtr&, Passenger::FileDescriptor&, const Passenger::AnalyticsLogPtr&)' (HelperAgent.cpp:330) 
    in 'void Client::handleRequest(Passenger::FileDescriptor&)' (HelperAgent.cpp:510) 
    in 'void Client::threadMain()' (HelperAgent.cpp:603) 

2011/08/31 15:25:49 [error] 21197#0: *41172 upstream prematurely closed connection while reading response header from upstream, client: 78.47.253.164, server: yandex.ru, request: "GET/HTTP/1.0", upstream: "passenger:unix:/passenger_helper_server:", host: "yandex.ru" 
[ pid=21257 thr=15884760 file=utils.rb:176 time=2011-08-31 15:25:49.032 ]: *** Exception PGError in application (server closed the connection unexpectedly 
    This probably means the server terminated abnormally 
    before or while processing the request. 
) (process 21257, thread #<Thread:0x00000001e4c3b0>): 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `exec' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `block in clear_cache!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:275:in `each_value' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:275:in `clear_cache!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:303:in `disconnect!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:202:in `block in disconnect!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `each' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `disconnect!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:35:in `block in disconnect_with_synchronization!' 
    from /home/deployer/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:34:in `disconnect_with_synchronization!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `block in clear_all_connections!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `each_value' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `clear_all_connections!' 
    from /home/deployer/yandex.ru/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `clear_all_connections!' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/utils.rb:398:in `before_handling_requests' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:204:in `start_request_handler' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:170:in `block in handle_spawn_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/utils.rb:479:in `safe_fork' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:180:in `start' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:128:in `start' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize' 
    from <internal:prelude>:10:in `synchronize' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' 
    from /home/deployer/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/helper-scripts/passenger-spawn-server:99:in `<main>' 

risposta

8

Ho trovato la soluzione da solo. C'è passenger_spawn_method conservative deve essere scritto in nginx.conf anziché il valore predefinito passenger_spawn_method conservative smart-lv2.

+1

Sembra che questo tipo di bug appare in connessione con ruby ​​1.9.2 + rotaie 3.1 + pag. – peanut

+0

sto ottenendo un [errore simile] (http : //stackoverflow.com/questions/7290878/rails-3-1-intermittent-500-internal-server-error-when-serving-uncompressed-asset), penso.Ma prendo il mio quando sto servendo asset Ho la stessa configurazione: 1.9.2, rails 3.1, pag. –

+0

Stessa cosa qui, Rails 3.1, pg, ruby ​​1.9.2, e sto usando Apache + Passenger – fivetwentysix

0

State assegnazione o gestire le proprie connessioni al database/piscine?

Passeggero riconnette il pool di database ActiveRecord predefinito per ogni worker in background dopo il fork.

Tuttavia, altre risorse o connessioni database gestite manualmente devono essere configurate/ricollegate manualmente per ciascun lavoratore dopo la foratura.

ho scritto un post sul blog dettagliata che spiega come risolvere questo problema: http://blog.winfieldpeterson.com/2011/01/06/passenger-resource-collision/

Questo suona come quello che stai vivendo, più lavoratori che cercano di condividere una singola connessione al database e producono errori sotto carico a causa di conflitti di risorse.

+0

Ci dispiace, ma non aiuta :( – peanut

Problemi correlati