Getting "PGError: no connection to the server" with spork running

Hey Guys,

This is probably not specific to Rails, but I’m kinda hoping someone already faced this error, it’s been hours trying to debug the issue, but I just can’t figure out why it’s happening

So the application I’m developing is on Rails 3.1 using the 3-1-stable branch, up-to-date, and I’m using latest version of all the Gems listed in the Gemfile below…

When I run guard with the guard-spork portion commented, everything works just fine, however, if I enable spork, I get the following error on the second time the tests run, that’s right, the first time the tests run like usual but If I save/touch any of the test file, rspec gets invoked and the following error is shown (all the tests fail of course).

Any hints?

Regards,

Wael

 Failure/Error: Unable to find matching line from backtrace

 PGError:

   no connection to the server

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in `exec'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in `block in clear_cache!'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:271:in `each_value'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:271:in `clear_cache!'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:286:in `reconnect!'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:167:in `verify!'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `block in checkout_and_verify'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activesupport/lib/active_support/callbacks.rb:390:in `_run_checkout_callbacks'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:314:in `checkout_and_verify'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:310:in `checkout_existing_connection'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:253:in `block (2 levels) in checkout'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:251:in `loop'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:251:in `block in checkout'

 # /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:250:in `checkout'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:152:in `connection'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:389:in `retrieve_connection'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:107:in `retrieve_connection'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/fixtures.rb:463:in `create_fixtures'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/fixtures.rb:928:in `load_fixtures'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-e402b688cc2e/activerecord/lib/active_record/fixtures.rb:894:in `setup_fixtures'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rspec-rails-2.6.1/lib/rspec/rails/adapters.rb:11:in `block (2 levels) in setup'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in `instance_eval'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in `run_in'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in `block in run_all'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in `each'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in `run_all'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:116:in `run_hook'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in `block in eval_before_eachs'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in `each'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in `eval_before_eachs'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:145:in `run_before_each'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:47:in `block in run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:107:in `with_around_hooks'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:45:in `run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:294:in `block in run_examples'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in `map'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in `run_examples'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:262:in `run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `block in run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `map'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `block in run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `map'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `block (2 levels) in run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `map'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `block in run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/reporter.rb:12:in `report'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:21:in `run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rspec-core-2.6.4/lib/rspec/monkey/spork/test_framework/rspec.rb:5:in `run_tests'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/run_strategy/forking.rb:13:in `block in run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/forker.rb:21:in `block in initialize'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/forker.rb:18:in `fork'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/forker.rb:18:in `initialize'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/run_strategy/forking.rb:9:in `new'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/run_strategy/forking.rb:9:in `run'

 # /usr/local/rvm/gems/ruby-1.9.2-p180/bundler/gems/spork-b15cfd209b5b/lib/spork/server.rb:48:in `run'

 # /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1558:in `perform_without_block'

 # /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1518:in `perform'

 # /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1592:in `block (2 levels) in main_loop'

 # /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in `loop'

 # /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in `block in main_loop'

Finished in 0.13198 seconds

13 examples, 13 failures

Gemfile:

PGP.sig (243 Bytes)

Hi Wael,

This is the Rubyonrails-core mailing list reserved for discussion regarding the core of the framework.

To get help with application specific problems please ask on rubyonrails-talk or stackoverflow.com

Thanks!

Is your PG service running? Does you app have authorized access to the DB? Is app pointed at right port? (new myself .. sorry if pointing you in obviously wrong simpleton solutions) :slight_smile:

ee

Yeah, everything is set.. Like I said, the tests passes the first time, but on the second run (invoked by guard), they don't..

I answered your question on SO :