Re: Add client connection check during the execution of the query
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>, Tatsuo Ishii <ishii@sraoss.co.jp>, Tom Lane <tgl@sss.pgh.pa.us>, Zhihong Yu <zyu@yugabyte.com>
Date: 2021-03-24T05:02:11Z
Lists: pgsql-hackers
Hi, On 2021-03-24 16:08:13 +1300, Thomas Munro wrote: > ... 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. It is indeed frustrating. I searched a bit for other OSs and POLLRDHUP and I'm annoyed by responses from various OS folks of "You don't need that, just read the data upon POLLIN...". I don't like the feature not handling pipelining etc, nor does working undetectedly only on linux seem like a great answer. I guess we could have the template files tell us wether it work, or configure test it, but brrr. I'm mostly joking, and I've not read the thread, but I assume just sending an empty NoticeResponse or error message has been brought up and laughed out of the room? > (I tried to make it work on Windows too by reading the manual, no idea > if that part compiles or works). If the patch had tests, cfbot might tell you :) Greetings, Andres Freund
Commits
-
Add WL_SOCKET_CLOSED for socket shutdown events.
- 50e570a59e7f 15.0 landed
-
Use WL_SOCKET_CLOSED for client_connection_check_interval.
- cba5b994c990 15.0 landed
-
Detect POLLHUP/POLLRDHUP while running queries.
- c30f54ad732c 14.0 landed
-
Improve timeout.c's handling of repeated timeout set/cancel.
- 09cf1d522676 14.0 cited