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
- What are these COMMIT/ROLLBACK idle sessions?
- How can I get these idle sessions to clear immediately?
- How can I reduce the number of these idle sessions from being created?
Thanks