RE: Add client connection check during the execution of the query

From: "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>
To: 'Thomas Munro' <thomas(dot)munro(at)gmail(dot)com>, Maksim Milyutin <milyutinma(at)gmail(dot)com>
Cc: 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>, Andres Freund <andres(at)anarazel(dot)de>, Zhihong Yu <zyu(at)yugabyte(dot)com>
Subject: RE: Add client connection check during the execution of the query
Date: 2021-04-01 09:16:38
Message-ID: TYAPR01MB2990F4C319FC852CCED60394FE7B9@TYAPR01MB2990.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
> I changed my mind. Let's commit the pleasingly simple Linux-only feature for
> now, and extend to it to send some kind of no-op message in a later release.
> So this is the version I'd like to go with.
> Objections?

+1, as some of our users experienced the problem that the server kept processing (IIRC, a buggy PL/pgSQL procedure that loops indefinitely) after they killed the client.

TBH, Linux and Windows will be sufficient. But I'm for providing a good feature on a specific OS first.

(1)
+ rc = poll(&pollfd, 1, 0);
+ if (rc < 0)
+ {
+ elog(COMMERROR, "could not poll socket: %m");
+ return false;

I think it's customary to use ereport() and errcode_for_socket_access().

(2)
pq_check_connection()

Following PostmasterIsAlive(), maybe it's better to name it as pq_connection_is_alive() pq_client_is_alive(), or pq_frontend_is_alive() like the pqcomm.c's head comment uses the word frontend?

(3)
#include <limits.h>
+#include <poll.h>
#ifndef WIN32
#include <sys/mman.h>
#endif

poll.h should be included between #ifndef WIN32 and #endif?

(4)
I think the new GUC works for walsender as well. If so, how do we explain the relationship between the new GUC and wal_receiver_timeout and recommend the settings of them?

Regards
Takayuki Tsunakawa

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2021-04-01 09:27:09 Re: Perform COPY FROM encoding conversions in larger chunks
Previous Message Michael Paquier 2021-04-01 08:49:03 Re: Flaky vacuum truncate test in reloptions.sql