"PGError: no connection to the server" after idle

Posted by user573484 on Stack Overflow See other posts from Stack Overflow or by user573484
Published on 2011-01-12T23:50:28Z Indexed on 2011/01/12 23:53 UTC
Read the original article Hit count: 352

Filed under:
|
|

After my application sits idle overnight, when I try to access it in the morning I get a 500 Internal server error and the logs indicate "PGError: no connection to the server". After this first request if I refresh the page again everything is fine.

I'm running Ubuntu 10.04 with apache 2, Passenger 3.0.2, Rails 2.3.8, and Postgres 8.4 on a remote server.

Any ideas how to fix this?

Here is the log:

Processing ApplicationController#index (for 192.168.1.33 at 2011-01-06 17:28:14) [GET]
  Parameters: {"action"=>"index", "controller"=>"da"}
ActiveRecord::StatementInvalid (PGError: no connection to the server
: SELECT * FROM "users" WHERE ("users"."id" = 1)  LIMIT 1):
  app/controllers/application_controller.rb:47:in `current_user'
  app/controllers/application_controller.rb:51:in `set_current_user'
  app/controllers/application_controller.rb:123:in `render_optional_error_file'
  passenger (3.0.2) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
  passenger (3.0.2) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
  passenger (3.0.2) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
  passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
  passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
  passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
  passenger (3.0.2) lib/phusion_passenger/utils.rb:479:in `safe_fork'
  passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
  passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
  passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:180:in `start'
  passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
  passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
  passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
  passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
  passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
  passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
  passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
  passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
  passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
  passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.2) helper-scripts/passenger-spawn-server:99
/!\ FAILSAFE /!\  Thu Jan 06 17:28:14 -0700 2011
  Status: 500 Internal Server Error
  PGError: no connection to the server
: SELECT * FROM "users" WHERE ("users"."id" = 1)  LIMIT 1
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:221:in `log'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/postgresql_adapter.rb:520:in `execute'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1002:in `select_raw'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/postgresql_adapter.rb:989:in `select'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:81:in `cache_sql'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:664:in `find_by_sql'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1578:in `find_every'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1535:in `find_initial'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:616:in `find'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1910:in `find_by_id'
    /home/user/application/releases/20110106230903/app/controllers/application_controller.rb:47:in `current_user'
    /home/user/application/releases/20110106230903/app/controllers/application_controller.rb:51:in `set_current_user'
    /home/user/application/releases/20110106230903/app/controllers/application_controller.rb:123:in `render_optional_error_file'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/rescue.rb:97:in `rescue_action_in_public'
    /home/user/application/releases/20110106230903/vendor/plugins/exception_notification/lib/exception_notification/notifiable.rb:48:in `rescue_action_in_public'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/rescue.rb:154:in `rescue_action_without_handler'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/rescue.rb:74:in `rescue_action'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:532:in `send'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:532:in `process_without_filters'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:606:in `process'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/rescue.rb:65:in `call_with_exception'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:90:in `dispatch'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:121:in `_call'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:130
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:29:in `call'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:29:in `call'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:9:in `cache'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:28:in `call'
    /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/string_coercion.rb:25:in `call'
    /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in `call'
    /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in `call'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/params_parser.rb:15:in `call'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/session/cookie_store.rb:99:in `call'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/failsafe.rb:26:in `call'
    /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
    /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `synchronize'
    /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
    /var/lib/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:106:in `call'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/utils.rb:479:in `safe_fork'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:180:in `start'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
    /var/lib/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
    /var/lib/gems/1.8/gems/passenger-3.0.2/helper-scripts/passenger-spawn-server:99

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about apache