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
database.yml
for your environment? Are you sure that your pg_hba.conf is correctly set up? – Semibreveparallel
... – Semibrevenew_signups = CustomerInputDatax::Record.where.not(:status => 'email_sent').all
– Niemangem whenever
and/or to run this command invoking a rake task instead of calling directly the activerecord model? – Semibreverufus_scheduler
from 3.4.2 to 3.3.4 and the system starts to access the table fine. It seems to be related to the newer version of rufus_scheduler. Will check outwhenever
. thank you. – Nieman