Re: 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: Re: How to automatically delete idle client connections?
Date: 2021-06-22 01:08:19
Message-ID: CALKrq=mTgbekbUWxuxrbCLRQm4DCKL-bXbrNzxvnG2gU3zKitw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ron , David

Thank you for the advice.

SQL statement had worked out in our environment and are also looking
forward to the new release.

Best Regards,
Yu Watanabe

On Tue, Jun 22, 2021 at 6:05 AM Ron <ronljohnsonjr(at)gmail(dot)com> wrote:

> On 6/21/21 5:17 AM, David Rowley wrote:
>
> On Mon, 21 Jun 2021 at 21:59, Yu Watanabe <yu(dot)w(dot)tennis(at)gmail(dot)com> <yu(dot)w(dot)tennis(at)gmail(dot)com> wrote:
>
> 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 ?
>
> There is idle_session_timeout in PostgreSQL 14, but that's not much
> use to you, since a) it's not out yet, and b) you're using 12.
>
> I guess you could do something like:
>
> SELECT pg_terminate_backend(pid) FROM pg_stat_Activity where state =
> 'idle' and state_change < NOW() - INTERVAL '1 hour';
>
> Change '1 hour' to whatever you like and maybe *set up a cron job* to run that.
>
>
> That's what we did.
>
> --
> Angular momentum makes the world go 'round.
>

--
Yu Watanabe

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-06-22 01:23:47 Re: Psql wants to use IP6 when connecting to self using tcp...
Previous Message Jerry Levan 2021-06-22 00:44:16 Psql wants to use IP6 when connecting to self using tcp...