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: 2021-12-13 04:51:00
Message-ID: CA+hUKG+GHmM1uYg7ix4WVLfFTNZW=vSTWOLHp5Vx=BDE24DT4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Dec 11, 2021 at 7:09 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Sat, Dec 11, 2021 at 6:11 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
> > Yuck. Is there really no better way to deal with this? What kind of errors is
> > this trying to handle transparently? Afaics this still changes when we'd
> > e.g. detect postmaster death.
>
> The problem is that WaitEventSetWait() only reports the latch, if it's
> set, so I removed it from the set (setting it to NULL), and then undo
> that afterwards. Perhaps we could fix that root problem instead.
> That is, we could make it so that latches aren't higher priority in
> that way, ie don't hide other events[1]. Then I wouldn't have to
> modify the WES here, I could just ignore it in the output event list
> (and make sure that's big enough for all possible events, as I had it
> in the last version). I'll think about that.

I tried that. It seems OK, and gets rid of the PG_FINALLY(), which is
nice. Latches still have higher priority, and still have the fast
return if already set and you asked for only one event, but now if you
ask for nevents > 1 we'll make the syscall too so we'll see the
WL_SOCKET_CLOSED.

It's possible that someone might want the old behaviour one day (fast
return even for nevents > 1, hiding other events), and then we'd have
to come up with some way to request that, which is the type of tricky
policy question that had put me off "fixing" this before. But I guess
we could cross that bridge if we come to it. Everywhere else calls
with nevents == 1, so that's hypothetical.

Better?

Attachment Content-Type Size
v4-0001-Add-WL_SOCKET_CLOSED-for-socket-shutdown-events.patch text/x-patch 7.8 KB
v4-0002-Don-t-let-latches-hide-other-WaitEventSet-events.patch text/x-patch 4.5 KB
v4-0003-Use-WL_SOCKET_CLOSED-for-client_connection_check_.patch text/x-patch 4.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2021-12-13 04:54:43 Re: parallel vacuum comments
Previous Message Amit Kapila 2021-12-13 04:04:29 Re: Skipping logical replication transactions on subscriber side