Tag Archives: rails

Checking Idle Transaction on Heroku’s Postgresql

If you ever have connection problem with your postgresql instance on heroku, this post might help you.

One time one of my resque workers is dead when running long query (deleteing ~80k rows in a table). After that I got tons of timeout errors from my app. I even can’t do DELETE and UPDATE from one-off dyno

First, lets check all the process connected to your heroku postgresql instance

heroku pg:ps -a appname

you can see if there is some “idle in transaction” process. It’s likely the culprit. Take notes of the pid, then kill it with

heroku pg:kill pid_number -a appname

After you kill all those idle processes, your database should be free again.