Postgres sessions are idle with query = COMMIT or ROLLBACK

Viewed 15075

I have a Postgres 9.5 database for a web-based Java application. Sometimes, the number of sessions suddenly spikes up due to a long running query, and these sessions are not cleared immediately. When I check pg_stat_activity, query column shows COMMIT or ROLLBACK with a stage of idle. This is causing Postgres to hit high thresholds of max_connections, which can possibly cause Production outage.

query | ROLLBACK state | idle count | 167

query | COMMIT state | idle count | 280

  1. What are these COMMIT/ROLLBACK idle sessions?
  2. How can I get these idle sessions to clear immediately?
  3. How can I reduce the number of these idle sessions from being created?

Thanks

1 Answers
Related