我在Linode上運行Ubuntu 11.04,我試圖獲得Rails 3.1,Nginx 1.0.6,Passenger 3.0.9和PostgreSQL 8.4的設置和運行。我設法部署了我的應用程序,並且它看起來都很完美,但是在幾次成功的HTTP請求之後,服務器開始返回502網關錯誤。我使用了相同的設置在我的OS X開發機器上(PostgreSQL 8.4,Rails 3.1和WEBrick),它的工作原理非常完美。我在Nginx日誌中看到了它,它似乎是PostgreSQL問題。Rails,Nginx和PostgreSQL - 502網關錯誤
有誰知道這個問題可能是什麼?
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/active_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
----------
謝謝!
我似乎已經通過在config/environments/production.rb中更改config.action_controller.perform_caching = false來解決這個問題,但我仍然無法弄清楚爲什麼緩存會導致Postgres錯誤,並且它不是一個真正可行的選項在生產模式下關閉緩存。 – rsl