PostgreSQL error

Hi All, I’m seeing intermittent Postgres errors in my rails app that are resulting in very long-running requests. I’ve googled this error, but all the results points to a problem with an earlier version of Rails that has supposedly been fixed, or to problems with gems I’m not using (Sideqik) . This is a low-traffic application, and I can’t see any pattern as to when the errors occur.

I’m running the following:

Rails 4.2.1

pg gem 0.18.2

ruby 2.2.0

Postgres 9.1.11, with max_connections=200, current connections ~90

Ubuntu 14.04.2

Passenger 5.0.8

The error is PG::UnableToSend (SSL SYSCALL error: EOF detected)

Stacktrace here.

Anyone have any idea what might be causing this, or how to track down a solution? Thanks!

Hi Christopher, Have you received any suggestions on this or found a solution. A google search shows some information. Tony

@tjones, This was a long time ago, but I believe the solution was to add reconnect: true to the DB config.

1 Like

Christopher, Thanks for getting back to me in something from such a long time ago. Most appreciated. Stay well. Thanks, Tony

I was just curious, is the reconnect: true option documented anywhere? I couldn’t seem to find it but maybe I missed an obvious spot.

Prior to Rails 7.1, reconnect is only a part of MySQL, and described here:

https://dev.mysql.com/doc/c-api/5.7/en/c-api-auto-reconnect.html

Starting with Rails 7.1, auto-reconnect behaviour becomes standard on all database adapters, as long as it’s an idempotent query. (Details from the changelog.)

The ability to set reconnect: true in database.yml was introduced in Rails 2.3:

Some additional info about reconnecting is found in Brian Lopez’s mysql2 gem.

1 Like