开发者

Rails, Nginx and PostgreSQL - 502 Gateway Errors

I'm running Ubuntu 11.04 on Linode and I'm trying to get Rails 3.1, Nginx 1.0.6, Passenger 3.0.9 and PostgreSQL 8.4 set-up and running. I've managed to deploy my application and it all appears to work perfectly but after a few successful HTTP requests the server begins to return 502 Gateway Errors.

I've looked in the Nginx log and it seems to be a PostgreSQL problem, I use the same set-up on my OS X development machine (PostgreSQL 8.4, Rails 3.1 and WEBrick) and it works perfectly.

Does anyone know what the problem could be?


2011/09/26 11:43:41 [error] 19694#0: *152 upstream prematurely closed connection while reading response header from upstream, client: <REDACTED>, server: localhost, request: "GET /news/new HTTP/1.0", upstream: "passenger:unix:/passenger_helper_server:", host: "<REDACTED>"
[ pid=19978 thr=-609427238 file=utils.rb:176 time=2011-09-26 11:43:41.504 ]: *** Exception PGError in application (server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.**
) (process 19978, thread #<Thread:0xb759c1b4>):
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `query'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `clear_cache!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:275:in `each_value'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/a开发者_开发技巧ctive_record/connection_adapters/postgresql_adapter.rb:275:in `clear_cache!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:303:in `disconnect!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:202:in `disconnect_without_synchronization!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `each'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `disconnect_without_synchronization!'
        from /var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:35:in `disconnect!'
        from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
        from /var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:34:in `disconnect!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `clear_all_connections!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `each_value'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `clear_all_connections!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `__send__'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `clear_all_connections!'
        from /opt/passenger-3.0.9/lib/phusion_passenger/utils.rb:398:in `before_handling_requests'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:204:in `start_request_handler'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:170:in `send'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:170:in `handle_spawn_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/utils.rb:479:in `safe_fork'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:180:in `start'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:128:in `start'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rack_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rack_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
        from /opt/passenger-3.0.9/helper-scripts/passenger-spawn-server:99

----------

Thanks!


What write to logs PostgreSQL in this case? There must be some reasons to close connection - maybe old version of PostgreSQL?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜