Re: Terminate the idle sessions

Japin Li <japinli@hotmail.com>

From: Li Japin <japinli@hotmail.com>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, "bharath.rupireddyforpostgres@gmail.com" <bharath.rupireddyforpostgres@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2020-08-31T02:40:37Z
Lists: pgsql-hackers

On Aug 31, 2020, at 8:51 AM, Thomas Munro <thomas.munro@gmail.com<mailto:thomas.munro@gmail.com>> wrote:

The main problem I have with it is the high frequency setitimer()
calls.  If you enable both statement_timeout and idle_session_timeout,
then we get up to huge number of system calls, like the following
strace -c output for a few seconds of one backend under pgbench -S
workload shows:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
39.45    0.118685           0    250523           setitimer
29.98    0.090200           0    125275           sendto
24.30    0.073107           0    126235       973 recvfrom
 6.01    0.018068           0     20950           pread64
 0.26    0.000779           0       973           epoll_wait
------ ----------- ----------- --------- --------- ----------------
100.00    0.300839                523956       973 total

Hi, Thomas,

Could you give the more details about the test instructions?

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.