Re: tcp keep alive don't work when the backend is busy

From: Fabio Ugo Venchiarutti <f(dot)venchiarutti(at)ocado(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Олег Самойлов <splarv(at)ya(dot)ru>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: tcp keep alive don't work when the backend is busy
Date: 2019-12-10 15:17:32
Message-ID: d931a32d-2ae6-d65d-af34-e52a551c634e@ocado.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/12/2019 15:06, Tom Lane wrote:
> =?utf-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg==?= <splarv(at)ya(dot)ru> writes:
>> According to the documentation
>> https://www.postgresql.org/docs/12/runtime-config-connection.html
>> A backend must check connection to the client by tcp_keepalive messages. (Config option tcp_keepalives_idle).
>
>> But this is don't work if the backend is busy.
>
> You're reading something into the documentation that isn't there.
>
> The TCP keepalive mechanism is something that the OS does, independently
> of backend processing. The backend isn't going to notice loss of client
> connection until it tries to read or write on the connection.
>
> If it were free to improve this, we might do so. But it would be
> very much not free.
>
> regards, tom lane
>
>

At what points does the backend bite the bullet to test the state of
that file descriptor?

I'd expect select() and poll() to return immediately when keepalive
probes timeout, so idling clients are covered (and that's the main use
case); does any other code path go out if its way to ensure that there's
still a client without actually needing to read()/write()/send()/recv()?
(obviously at the cost you mentioned)

--
Regards

Fabio Ugo Venchiarutti
OSPCFC Network Engineering Dpt.
Ocado Technology

--

Notice:
This email is confidential and may contain copyright material of
members of the Ocado Group. Opinions and views expressed in this message
may not necessarily reflect the opinions and views of the members of the
Ocado Group.

If you are not the intended recipient, please notify us
immediately and delete all copies of this message. Please note that it is
your responsibility to scan this message for viruses.

References to the
"Ocado Group" are to Ocado Group plc (registered in England and Wales with
number 7098618) and its subsidiary undertakings (as that expression is
defined in the Companies Act 2006) from time to time. The registered office
of Ocado Group plc is Buildings One & Two, Trident Place, Mosquito Way,
Hatfield, Hertfordshire, AL10 9UL.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message stan 2019-12-10 15:32:55 Re: server will not start (Debian)
Previous Message Tom Lane 2019-12-10 15:06:27 Re: tcp keep alive don't work when the backend is busy