Postgres Connection Issues causing workers to freeze

3,094 views
Skip to first unread message

Nick DeSteffen

unread,
Jul 21, 2015, 3:24:47 PM7/21/15
to Sidekiq
We recently upgraded to Ruby 2.2.2 (from 2.0-p481) and have started getting strange Postgres connection errors periodically.  These errors cause our Sidekiq workers to just hang and not finish their jobs or pickup any new ones.  

Some of the errors we have encountered are:
  • PG::UnableToSend: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
  • PG::ConnectionBad: PQsocket() can't get socket descriptor
  • PG::ConnectionBad: ERROR: no more connections allowed (max_client_conn)
  • PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
We are running Postgres 9.3.6, Sidekiq 3.4.1 (concurrency set to 32 in production), Ruby 2.2.2, Rails 4.1.12, pg gem (0.18.2).  We had sidekiq-limit_fetch (2.4.2) running but removed that in case it was the root of the problem, but it isn't.  Our application is connecting to the database via PgBouncer, however we had these problems prior to connecting through PgBouncer. 

Restarting Sidekiq causes the jobs to clear out and finish.

Any help would be appreciated.

Regards,
Nick

Mike Perham

unread,
Jul 22, 2015, 11:46:11 AM7/22/15
to sid...@googlegroups.com
That looks like a connection corruption error that people have reported before.  I suspect the problem is somewhere in MRI/openssl/pg because no one with mysql reports the same issue.  Perhaps it's a threading issue; you can bump concurrency down to 1 and see if the problem disappears too.  Sadly I don't have any idea how to solve it.

Mike

--
You received this message because you are subscribed to the Google Groups "Sidekiq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+u...@googlegroups.com.
To post to this group, send email to sid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sidekiq/bda7c3d2-ae03-4bc5-a4ae-35e3a7bd9203%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mike Perham – CEO, Contributed Systems
Smart, effective open source infrastructure for your apps.

Nick DeSteffen

unread,
Aug 5, 2015, 11:04:24 AM8/5/15
to Sidekiq

Mike,


Just an update here, we configured activerecord's reaper in our application and the exceptions seem to have subsided.  So far we don't see any side effects.  If anybody else has this problem they can try adding the configuration setting to their database.yml


reaping_frequency: 10


10 being the number of seconds between each reaper run.


Thanks,

Nick

Mike Perham

unread,
Aug 5, 2015, 1:08:04 PM8/5/15
to sid...@googlegroups.com
Nick, that's awesome info.  I will add that to the troubleshooting wiki page, thanks for following up.


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages