PG::UnableToSend: no connection to the server in Rails

Viewed 10376

I have a production server running ubuntu 14.04, Rails 4.2.0, postgresql 9.6.1 with gem pg 0.21.0/0.20.0. In last few days, there is constantly error with accessing to a table customer_input_datax_records in psql server.

D, [2017-07-20T18:08:39.166897 #1244] DEBUG -- :   CustomerInputDatax::Record Load (0.1ms)  SELECT "customer_input_datax_records".* FROM "customer_input_datax_records" WHERE ("customer_input_datax_records"."status" != $1)  [["status", "email_sent"]]
E, [2017-07-20T18:08:39.166990 #1244] ERROR -- : PG::UnableToSend: no connection to the server
: SELECT "customer_input_datax_records".* FROM "customer_input_datax_records" WHERE ("customer_input_datax_records"."status" != $1)

The code which call to access the db server is with Rufus scheduler 3.4.2 loop:

s = Rufus::Scheduler.singleton
s.every '2m' do

    new_signups = CustomerInputDatax::Record.where.not(:status => 'email_sent').all

.......
end

After restart the server, usually there is with first request (or a few). But after some time (ex, 1 or 2 hours), the issue starts to show up. But the app seems running fine (accessing records with read/write & creating new). There are some online posts about the error. However the problem seems not the one I am having. Before I re-install the psql server, I would like to get some ideas about what causes the no connection.

UPDATE: database.yml

production:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: wb_production
  pool: 5
  username: postgres
  password: xxxxxxx
2 Answers
Related