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

From Stas Kelvich
Subject Re: Add client connection check during the execution of the query
Date
Msg-id 37D9769E-2991-46A9-A65B-498E3CF55D8C@postgrespro.ru
Whole thread Raw
In response to Re: Add client connection check during the execution of the query  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: Add client connection check during the execution of the query  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers

> On 5 Jul 2019, at 11:46, Thomas Munro <thomas.munro@gmail.com> wrote:
> 
> On Fri, Jul 5, 2019 at 6:28 PM Tatsuo Ishii <ishii@sraoss.co.jp> wrote:
>>> The purpose of this patch is to stop the execution of continuous
>>> requests in case of a disconnection from the client.
>> 
>> Pgpool-II already does this by sending a parameter status message to
>> the client. It is expected that clients are always prepared to receive
>> the parameter status message. This way I believe we could reliably
>> detect that the connection to the client is broken or not.
> 
> Hmm.  If you send a message, it's basically application-level
> keepalive.  But it's a lot harder to be sure that the protocol and
> socket are in the right state to insert a message at every possible
> CHECK_FOR_INTERRUPT() location.  Sergey's proposal of recv(MSG_PEEK)
> doesn't require any knowledge of the protocol at all, though it
> probably does need TCP keepalive to be configured to be useful for
> remote connections.


Well, indeed in case of cable disconnect only way to detect it with
proposed approach is to have tcp keepalive. However if disconnection
happens due to client application shutdown then client OS should itself
properly close than connection and therefore this patch will detect
such situation without keepalives configured.

--
Stas Kelvich
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company





pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: using explicit_bzero
Next
From: Nikolay Shaplov
Date:
Subject: Why vacuum_index_cleanup is needed for TOAST relations?