Re: Terminate the idle sessions
Japin Li <japinli@hotmail.com>
From: Li Japin <japinli@hotmail.com>
To: Cary Huang <cary.huang@highgo.ca>, "david.g.johnston@gmail.com" <david.g.johnston@gmail.com>
Cc: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2020-08-11T03:14:58Z
Lists: pgsql-hackers
Attachments
- v2-0001-Allow-terminating-the-idle-sessions.patch (application/octet-stream) patch v2-0001
Hi, On Aug 11, 2020, at 5:42 AM, Cary Huang <cary.huang@highgo.ca<mailto:cary.huang@highgo.ca>> wrote: I applied this patch to the PG13 branch and generally this feature works as described. The new "idle_session_timeout" that controls the idle session disconnection is not in the default postgresql.conf and I think it should be included there with default value 0, which means disabled. Thanks for looking at it! I’ve attached a new version that add “idle_session_timeout” in the default postgresql.conf. On Mon, Aug 10, 2020 at 2:43 PM Cary Huang <cary.huang@highgo.ca<mailto:cary.huang@highgo.ca>> wrote: There is currently no enforced minimum value for "idle_session_timeout" (except for value 0 for disabling the feature), so user can put any value larger than 0 and it could be very small like 500 or even 50 millisecond, this would make any psql connection to disconnect shortly after it has connected, which may not be ideal. Many systems I have worked with have 30 minutes inactivity timeout by default, and I think it would be better and safer to enforce a reasonable minimum timeout value I'd accept a value of say 1,000 being minimum in order to reinforce the fact that a unit-less input, while possible, is taken to be milliseconds and such small values most likely mean the user has made a mistake. I would not choose a minimum allowed value solely based on our concept of "reasonable". I don't imagine a value of say 10 seconds, while seemingly unreasonable, is going to be unsafe. I think David is right, see “idle_in_transaction_session_timeout”, it also doesn’t have a “reasonable” minimum value.
Commits
-
Rethink SQLSTATE code for ERRCODE_IDLE_SESSION_TIMEOUT.
- 4edf96846a02 14.0 landed
-
Improve commentary in timeout.c.
- 9486e7b666fd 14.0 landed
-
Add idle_session_timeout.
- 9877374bef76 14.0 landed
-
Improve timeout.c's handling of repeated timeout set/cancel.
- 09cf1d522676 14.0 landed