Re: Add client connection check during the execution of the query - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: Add client connection check during the execution of the query
Date
Msg-id CA+hUKGL9LLNE8_+rBkRzBhmXA1XHEzJVqQr4T4fqzngqp66=-g@mail.gmail.com
Whole thread Raw
In response to Re: Add client connection check during the execution of the query  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
Responses Re: Add client connection check during the execution of the query  (Andres Freund <andres@anarazel.de>)
Re: Add client connection check during the execution of the query  (Maksim Milyutin <milyutinma@gmail.com>)
List pgsql-hackers
Going back a couple of years to something Konstantin said:

On Sat, Aug 3, 2019 at 4:40 AM Konstantin Knizhnik
<k.knizhnik@postgrespro.ru> wrote:
> But I wonder why we can not perform just pool with POLLOUT flag and zero
> timeout.
> If OS detected closed connection, it should return POLLHUP, should not it?
> I am not sure if it is more portable or more efficient way - just seems
> to be a little bit more natural way (from my point of view) to check if
> connection is still alive.

... Andres just asked me the same question, when we were discussing
the pq_peekmessage() patch (v7).  I had remembered that POLLHUP didn't
work for this type of thing, from some earlier attempt at something
similar, and indeed on my first attempt to do that here as an
alternative design, it did not work... with TCP sockets (localhost)...
though it did work with Unix sockets.  Gah!  Then he pointed me at
POLLRDHUP (a Linux only extension) and that did seem to work in all
cases I tried.  But without that, this v8 patch doesn't seem to work
on FreeBSD (TCP), and for the rest of the menagerie, who knows?
Here's a sketch patch like that for discussion.

It's frustrating, because this patch is so simple, and doesn't have
v7's problem with pipelined queries.  Hmm.

(I tried to make it work on Windows too by reading the manual, no idea
if that part compiles or works).

Attachment

pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?
Next
From: Peter Geoghegan
Date:
Subject: Re: 64-bit XIDs in deleted nbtree pages