Re: Terminate the idle sessions

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Li Japin <japinli@hotmail.com>
Cc: "kuroda.hayato@fujitsu.com" <kuroda.hayato@fujitsu.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, Thomas Munro <thomas.munro@gmail.com>, "bharath.rupireddyforpostgres@gmail.com" <bharath.rupireddyforpostgres@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2020-11-17T02:53:59Z
Lists: pgsql-hackers
On Monday, November 16, 2020, Li Japin <japinli@hotmail.com> wrote:

>
> <note>
> Consider setting this for specific users instead of as a server default.
> Client connections managed by connection poolers, or initiated indirectly
> like those by a remote postgres_fdw using server, should probably be
> excluded from this timeout.
>
>         <note>
>
>          <para>
> -         This parameter should be set to zero if you use postgres_fdw or
> some
> -         connection-pooling software, because connections might be closed
> unexpectedly.
> +         This parameter should be set to zero if you use some
> connection-pooling software, or
> +         PostgreSQL servers used by postgres_fdw, because connections
> might be closed unexpectedly.
>          </para>
>         </note>
>
>
Prefer mine, “or pg servers used by postgres_fdw”, doesn’t flow.


> Could you please explain how the idle-in-transaction interfere the
> long-running stability?
>

From the docs (next section):

This allows any locks held by that session to be released and the
connection slot to be reused; it also allows tuples visible only to this
transaction to be vacuumed. See Section 24.1
<https://www.postgresql.org/docs/13/routine-vacuuming.html> for more
details about this.

David J.

Commits

  1. Rethink SQLSTATE code for ERRCODE_IDLE_SESSION_TIMEOUT.

  2. Improve commentary in timeout.c.

  3. Add idle_session_timeout.

  4. Improve timeout.c's handling of repeated timeout set/cancel.