How to automatically delete idle client connections?

From: Yu Watanabe <yu(dot)w(dot)tennis(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: How to automatically delete idle client connections?
Date: 2021-06-21 09:58:57
Message-ID: CALKrq=k_QWHBWtDwmE-95mKC8FNX9wOz=1zJMRVwVeLhkRRLGg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear community.

I would like to ask a question regarding the below error occurred when
using psql client.
My environment is postgresql 12.3 docker container.
https://hub.docker.com/layers/postgres/library/postgres/12.3/images/sha256-23839ca029051ca19072dc7f40b252ae8cbcd7ef632f7b8e2da09ba3abc60214?context=explore

###
psql: error: could not connect to server: FATAL remaining connection slots
are reserved for non-replication superuser connections
###

It seems that this is caused by unused psql client sessions. Which was
caused by closing the terminal without exiting the psql session correctly.

###
postgres=# select usename,state,client_port from pg_stat_activity;
usename | state | client_port
----------+--------+-------------
| |
postgres | |
catseye | idle | -1
catseye | idle | 36718
catseye | idle | -1
catseye | idle | 52960
catseye | idle | 40854
...
###

I have tried setting *idle_in_transaction_session_timeout* , however,
this does not delete idle sessions.

Would there be any expiry settings to delete client idle sessions
automatically ?

My apology if this question was asked before but I appreciate it if someone
gives me advice.

Best Regards,
Yu Watanabe

--
Yu Watanabe

linkedin: www.linkedin.com/in/yuwatanabe1/
twitter: twitter.com/yuwtennis

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Rowley 2021-06-21 10:17:48 Re: How to automatically delete idle client connections?
Previous Message Avi Weinberg 2021-06-21 08:24:07 Is it Possible to Rename Replication Slot + Can Publisher be Paused