6

I've got source of Diaspora cloned and I've got a working local pod that seems to run without a hitch. But when I run $ rake spec some initial tests pass and then all of them start failing. Also, what I found interesting was that they fail at different points each time rake spec is run.

They all fail with the error:

An error occurred in an after hook
  ActiveRecord::StatementInvalid: PG::ConnectionBad: PQsocket() can't get socket descriptor: ROLLBACK
  occurred at /home/darshan/.rvm/gems/ruby-2.0.0-p353@diaspora/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:650:in `async_exec'

Postgres' log said:

could not receive data from client: Connection reset by peer
unexpected EOF on client connection
Darshan Rai
  • 130
  • 8
  • did u run $ rake db:test:prepare – Rahul Singh Feb 12 '14 at 18:19
  • Yes, @RahulSingh, I did. – Darshan Rai Feb 12 '14 at 18:38
  • post your `database.yml` – gotva Feb 12 '14 at 21:14
  • @gotva, here it is: http://pastebin.com/1pjxd8A0 – Darshan Rai Feb 13 '14 at 11:35
  • (strange I don't have a good suggest) What about trying to run a console or server in test env `RAILS_ENV=test rails c` and run some simplest queries. does it work? – gotva Feb 13 '14 at 15:14
  • @gotva, seems to work without any problems. _Even_ `RAILS_ENV=test rails s` works fine. – Darshan Rai Feb 13 '14 at 18:35
  • I haven't met similar situation. If app works in test env correctly and some tests are passed then the problem in tests. Do you use not trivial things in them? Maybe paralel testing, maybe some gems for integration testing. – gotva Feb 13 '14 at 20:37
  • 1
    Looks like a connection or performance problems rather than the configuration. Is your test database located on remote host ? – pawel7318 Apr 04 '14 at 10:21
  • @DarshanRai did you get to make it work? have the same issue – ishwr May 12 '14 at 14:33
  • 1
    @ishwr I switched to using MySQL and that worked for me. It was a very strange bug and I'm not sure what caused it. – Darshan Rai Jun 19 '14 at 09:40
  • I have this issue as well. I'm using version 0.18.1 of the `pg` gem (the latest at time of writing) and my spec runs regularly start failing with this error part way through and never recover. – Ivar Jan 13 '15 at 23:15
  • Here's a [related question](http://stackoverflow.com/questions/23626372/rspec-pgconnectionbad-pqsocket-cant-get-socket-descriptor) to this issue that's not Diaspora specific. – Ivar Feb 20 '15 at 17:31
  • I had this same problem; for me it happened during a long-running `delayed_job` that imports some records from a CSV file. Like @DarshanRai, I switched to MySQL, and that solved the problem. – Scott Weldon Mar 30 '15 at 23:05

3 Answers3

3

I ran into the same problem and found that by using the local unix socket file, rather than accessing the Postgres server via localhost, the problem seems to have gone away.

To achieve this, remove the host: localhost from your database.yml file, and re-run rake spec. This defaults back to the local socket file (usually .s.PGSQL.5432 in /tmp or /var/run/postgres, depending on your platform.)

Dan Garland
  • 3,350
  • 1
  • 24
  • 24
0

I ran into the same problem. I tried reverting to pg version 0.18.0 instead of 0.18.1, and that seems to fix it for me.

Community
  • 1
  • 1
BJ McDuck
  • 164
  • 1
  • 12
0

Go to postgres.conf and change ssl = true to ssl = false

I found the fix for this issue here and it worked for me.

Migore
  • 1,477
  • 3
  • 19
  • 40