Re: Add client connection check during the execution of the query

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Maksim Milyutin <milyutinma(at)gmail(dot)com>, "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Zhihong Yu <zyu(at)yugabyte(dot)com>
Subject: Re: Add client connection check during the execution of the query
Date: 2022-01-11 09:59:13
Message-ID: CA+hUKGK1VxwNVa5PuP=EOZY=SXQ=757efiQLd_-_FgiAiagc4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 14, 2021 at 11:50 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Tue, Dec 14, 2021 at 11:18 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)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.

Attachment Content-Type Size
v6-0001-Add-WL_SOCKET_CLOSED-for-socket-shutdown-events.patch text/x-patch 7.8 KB
v6-0002-Use-WL_SOCKET_CLOSED-for-client_connection_check_.patch text/x-patch 5.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ronan Dunklau 2022-01-11 10:05:26 Re: Proposal: More structured logging
Previous Message Amit Kapila 2022-01-11 09:48:19 Re: row filtering for logical replication