New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with postgres & spring: PG::ConnectionBad: PQsocket() can't get socket descriptor #910

Closed
vovimayhem opened this Issue Apr 30, 2017 · 1 comment

Comments

2 participants
@vovimayhem

vovimayhem commented Apr 30, 2017

I'm working on a legacy-code project running on Rails 3.2.21, and I'm currently isolating problems with rspec, spring & postgres.

Several gems in the project are adding modules to ActiveRecord::Base on load phase, and somehow this is attempting a connection before spring's forking of processes.

This causes that whenever I run rspec when the app has been already pre-loaded on spring (due to previously running rspec) to raise the following error:

ActiveRecord::StatementInvalid:
  PG::ConnectionBad: PQsocket() can't get socket descriptor:           SELECT tablename
            FROM pg_tables
            WHERE schemaname = ANY (current_schemas(false))

I suspect this is no longer the case on Rails >= 4.x, but maybe I'm wrong.

I fixed it on my case changing lib/searchkick.rb:210:

ActiveSupport.on_load :active_record do
  send :extend, Searchkick::Model
end if defined?(ActiveRecord)

Is anyone else experiencing this?

I think, regardless of this causing trouble or not, that the Searchkick::Model module must be added to ActiveRecord::Base inside this proposed hook.

What do you think?

@ankane ankane closed this in 1fb35cc Apr 30, 2017

@ankane

This comment has been minimized.

Show comment
Hide comment
@ankane

ankane Apr 30, 2017

Owner

Hey @vovimayhem, thanks for the detailed report 👍 Updated on master.

Owner

ankane commented Apr 30, 2017

Hey @vovimayhem, thanks for the detailed report 👍 Updated on master.

mikelkew added a commit to mikelkew/searchkick that referenced this issue May 1, 2017

Merge commit '1fb35cc0f183480e018daa8a5da6b163f22732bd' into handle_h…
…ashie

* commit '1fb35cc0f183480e018daa8a5da6b163f22732bd': (27 commits)
  Use better ActiveRecord hook - fixes ankane#910
  Removed unnecessary option [skip ci]
  Updated readme
  resolve customizable queue name as requested in ankane#799 (ankane#909)
  Updated tests to ES 5.3.2
  fix bulk index without IDs ankane#907 (ankane#908)
  Updated tests to ActiveRecord 5.1
  Version bump to 2.2.1
  Added index_suffix option - ankane#891
  Added load: {dumpable: true} option - closes ankane#887
  Test on Elasticsearch 5.3
  Updated changelog [skip ci]
  Support avg, cardinality, min, max and sum metric aggregates (ankane#877)
  Support cardinality metric aggregator (ankane#876)
  Improved exclude example [skip ci]
  Accept string for exclude option
  Improved synonyms section [skip ci]
  Added test for OR operator scoring
  Version bump to 2.2.0
  Fixed exclude case for exact match
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment