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-14 06:30:07
Message-ID: CA+hUKGL1uR0qKy3Hy8-9aFU=jxcGedaKqYTx_gRdyRg0p7cKGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 14, 2022 at 4:35 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
> The more I think about it, the less I see why we *ever* need to re-arm the
> latch in pq_check_connection() in this approach. pq_check_connection() is only
> used from from ProcessInterrupts(), and there's plenty things inside
> ProcessInterrupts() that can cause latches to be reset (e.g. parallel message
> processing causing log messages to be sent to the client, causing network IO,
> which obviously can do a latch reset).

Thanks for the detailed explanation. I guess I was being overly
cautious and a little myopic, "leave things exactly the way you found
them", so I didn't have to think about any of that. I see now that
the scenario I was worrying about would be a bug in whatever
latch-wait loop happens to reach this code. Alright then, here is
just... one... more... patch, this time consuming any latch that gets
in the way and retrying, with no restore.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2022-01-14 06:34:49 Re: relcache not invalidated when ADD PRIMARY KEY USING INDEX
Previous Message kato-sho@fujitsu.com 2022-01-14 05:30:27 Re: fix crash with Python 3.11