Re: Handling idle connections

Поиск
Список
Период
Сортировка
От Erik Wienhold
Тема Re: Handling idle connections
Дата
Msg-id kd2wgxkkdydj55fmu5hrewi2xtdb47t3l4kzv7xryd2b7rpxmk@zdqaigztd5pa
обсуждение исходный текст
Ответ на Handling idle connections  (Rajesh Kumar <rajeshkumar.dba09@gmail.com>)
Список pgsql-admin
On 2023-09-24 12:57 +0530, Rajesh Kumar wrote:
> What is the best way to handle idle connections other than manually killing
> idle connections if I do not have connection pooler.

Couple of options depending on your Postgres version and whether you
only care about idle connections with open transactions:

* set idle_in_transaction_session_timeout [1] for idle connections with
  an open transaction

* set idle_session_timeout [2] (requires pg14+) for idle connections
  without an open transaction

* use a cron job that checks connections in view pg_stat_activity and
  terminates them as necessary

[1]
https://www.cybertec-postgresql.com/en/idle_in_transaction_session_timeout-terminating-idle-transactions-in-postgresql/
[2] https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-IDLE-SESSION-TIMEOUT

-- 
Erik



В списке pgsql-admin по дате отправления:

Предыдущее
От: Scott Ribe
Дата:
Сообщение: Re: Handling idle connections
Следующее
От: Zhaoxun Yan
Дата:
Сообщение: Re: Corruption issue