Re: Add client connection check during the execution of the query
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Maksim Milyutin <milyutinma@gmail.com>, "tsunakawa.takay@fujitsu.com" <tsunakawa.takay@fujitsu.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>, Tatsuo Ishii <ishii@sraoss.co.jp>, Tom Lane <tgl@sss.pgh.pa.us>,
Zhihong Yu <zyu@yugabyte.com>
Date: 2022-01-11T09:59:13Z
Lists: pgsql-hackers
Attachments
- v6-0001-Add-WL_SOCKET_CLOSED-for-socket-shutdown-events.patch (text/x-patch) patch v6-0001
- v6-0002-Use-WL_SOCKET_CLOSED-for-client_connection_check_.patch (text/x-patch) patch v6-0002
On Tue, Dec 14, 2021 at 11:50 PM Thomas Munro <thomas.munro@gmail.com> wrote: > On Tue, Dec 14, 2021 at 11:18 AM Thomas Munro <thomas.munro@gmail.com> wrote: > > Well, I was trying to avoid bikeshedding an API change just for a > > hypothetical problem we could solve when the time comes (say, after > > fixing the more egregious problems with Append's WES usage), but here > > goes: we could do something like AddWaitEventToSet(FeBeWaitSet, > > WL_LATCH_SET_LOPRIO, ...) that is translated to WL_LATCH_SET > > internally but also sets a flag to enable this > > no-really-please-poll-all-the-things-if-there-is-space behaviour. That API is probably useless for anything else and is just too complicated for what it's doing here. I considered another idea we discussed: if we see a latch event, clear it and try again so that other events can be revealed (rince and repeat), but remember if that happens and set the latch at the end. I think that still requires PG_FINALLY() if you want to guarantee not to eat a latch event if WaitEventSetWait() throws. This may be a theoretical point because things must be pretty broken if WaitEventSetWait() is throwing, but I don't like an egregious lack of exception safety on principle. So I think I had it better in the beginning: just mute the latch, and then unmute it at the end in a PG_FINALLY() block. I'm back to proposing that short and sweet version, this time with some minor cleanup.
Commits
-
Add WL_SOCKET_CLOSED for socket shutdown events.
- 50e570a59e7f 15.0 landed
-
Use WL_SOCKET_CLOSED for client_connection_check_interval.
- cba5b994c990 15.0 landed
-
Detect POLLHUP/POLLRDHUP while running queries.
- c30f54ad732c 14.0 landed
-
Improve timeout.c's handling of repeated timeout set/cancel.
- 09cf1d522676 14.0 cited