Re: PQcancel does not use tcp_user_timeout, connect_timeout and keepalive settings

Поиск
Список
Период
Сортировка
От Zhihong Yu
Тема Re: PQcancel does not use tcp_user_timeout, connect_timeout and keepalive settings
Дата
Msg-id CALNJ-vSbOyVm9nk3y1UwA3e+M8atwJtTg_3ugRfC5W+TyAbMZQ@mail.gmail.com
обсуждение исходный текст
Ответ на PQcancel does not use tcp_user_timeout, connect_timeout and keepalive settings  (Jelte Fennema <Jelte.Fennema@microsoft.com>)
Ответы Re: [EXTERNAL] Re: PQcancel does not use tcp_user_timeout, connect_timeout and keepalive settings  (Jelte Fennema <Jelte.Fennema@microsoft.com>)
Список pgsql-hackers


On Thu, Sep 30, 2021 at 7:45 AM Jelte Fennema <Jelte.Fennema@microsoft.com> wrote:
The new connection made by PQcancel does not use the tcp_user_timeout, connect_timeout or any of the keepalive settings that are provided in the connection string. This means that a call to PQcancel can block for a much longer time than intended if there are network issues. This can be especially impactful, because PQcancel is a blocking function an there is no non blocking version of it.

I attached a proposed patch to use the tcp_user_timeout from the connection string when connecting to Postgres in PQcancel. This resolves the issue for me, since this will make connecting timeout after a configurable time. So the other options are not strictly needed. It might still be nice for completeness to support them too though. I didn't do this yet, because I first wanted some feedback and also because implementing connect_timeout would require using non blocking TCP to connect and then use select to have a timeout.

Hi,

    int         be_key;         /* key of backend --- needed for cancels */
+   int         pgtcp_user_timeout; /* tcp user timeout */ 

The other field names are quite short. How about naming the field tcp_timeout ?

Cheers

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jelte Fennema
Дата:
Сообщение: PQcancel does not use tcp_user_timeout, connect_timeout and keepalive settings
Следующее
От: Jelte Fennema
Дата:
Сообщение: Re: [EXTERNAL] Re: Add ETIMEDOUT to ALL_CONNECTION_FAILURE_ERRNOS