Getting PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly in a Rails Sidekiq job


I migrated a Rails app from Heroku, and in Sidekiq after a long job that takes more than 1 hour to complete I’m getting this error when the job tries to access the Postgres DB:

I’m not seeing anything suspicious in the logs and metrics.

Anyone else had a similar problem?