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-31T05:33:02Z
Lists: pgsql-hackers
Attachments
- v3-0001-Allow-terminating-the-idle-sessions.patch (application/octet-stream) patch v3-0001
- v3-0002-Optimize-setitimer-usage.patch (application/octet-stream) patch v3-0002
> On Aug 31, 2020, at 11:43 AM, Thomas Munro <thomas.munro@gmail.com> wrote: > > On Mon, Aug 31, 2020 at 2:40 PM Li Japin <japinli@hotmail.com> wrote: >> Could you give the more details about the test instructions? > > Hi Japin, > > Sure. Because I wasn't trying to get reliable TPS number or anything, > I just used a simple short read-only test with one connection, like > this: > > pgbench -i -s10 postgres > pgbench -T60 -Mprepared -S postgres > > Then I looked for the active backend and ran strace -c -p XXX for a > few seconds and hit ^C to get the counters. I doubt the times are > very accurate, but the number of calls is informative. > > If you do that on a server running with -c statement_timeout=10s, you > see one setitimer() per transaction. If you also use -c > idle_session_timeout=10s at the same time, you see two. Hi, Thomas, Thanks for your point out this problem, here is the comparison. Without Optimize settimer usage: % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 41.22 1.444851 1 1317033 setitimer 28.41 0.995936 2 658622 sendto 24.63 0.863316 1 659116 599 recvfrom 5.71 0.200275 2 111055 pread64 0.03 0.001152 2 599 epoll_wait 0.00 0.000000 0 1 epoll_ctl ------ ----------- ----------- --------- --------- ---------------- 100.00 3.505530 2746426 599 total With Optimize settimer usage: % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 49.89 1.464332 1 1091429 sendto 40.83 1.198389 1 1091539 219 recvfrom 9.26 0.271890 1 183321 pread64 0.02 0.000482 2 214 epoll_wait 0.00 0.000013 3 5 setitimer 0.00 0.000010 2 5 rt_sigreturn 0.00 0.000000 0 1 epoll_ctl ------ ----------- ----------- --------- --------- ---------------- 100.00 2.935116 2366514 219 total Here’s a modified version of Thomas’s patch.
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