In my rake task, I'm connecting to postgresql via a pgbouncer setup. For some queries I receive this error:
ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could not receive data from server: Connection timed out
In my pgbouncer log, I see this entry:
closing because: client unexpected eof (age=3110)
I have disabled prepared statements in my config/database.yml
file and enabled transaction
pool_mode
in my pgbouncer config file.
When I directly connect to postgres, I don't get this error.
Also in my rake task, I am creating multiple threads. I tried running ActiveRecord::Base.connection.reconnect!
inside my threads as suggested here. That didn't help either.
I am using rails version 4.2.5 which has this fix. I'm still getting this error "could not receive data from server: Connection timed out".
This was caused due to network issues in clients. Not able to reproduce since we migrated both server and client to Google Cloud Platform. Earlier our server was in DigitalOcean while our clients were in GCP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With