Re: Add client connection check during the execution of the query
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Konstantin Knizhnik <k.knizhnik@postgrespro.ru>
Cc: Tatsuo Ishii <ishii@sraoss.co.jp>, Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2021-03-06T04:06:12Z
Lists: pgsql-hackers
Attachments
- v4-0001-Detect-dropped-connections-while-running-queries.patch (text/x-patch) patch v4-0001
- v4-0002-some-fixups.patch (text/x-patch) patch v4-0002
On Mon, Mar 1, 2021 at 6:18 PM Thomas Munro <thomas.munro@gmail.com> wrote: > I've done a quick rebase of this the patch and added it to the > commitfest. No other changes. Several things were mentioned earlier > that still need to be tidied up. Rebased again due to bitrot. This time I did some actual work: 1. I didn't like the way it was rearming the timer *in the timer handler*; I think it should be done in the CFI(), and only if it determines that you're still running a query (otherwise you'll get periodic wakeups while you're idle between quieries, which is bad for the arctic ice cap; we already handle client going away efficiently between queries with WaitEventSet socket readiness). 2. The timer handler surely has to set the latch to close a race (cf. other similar handlers; between the CFI() and the beginning of the sleep, you could handle the signal, set the flag, and then go to sleep for 100 years). 3. The test might as well use pg_sleep() instead of doing a plpgsql busy loop of SELECT queries. 4. I prefer the name CLIENT_CONNECTION_CHECK_TIMEOUT instead of SKIP_CLIENT_CHECK_TIMEOUT; let's make up only one new name for a concept instead of two. 5. Miniscule doc change. I put these into a separate patch for ease of review. I don't claim this is ready -- still needs more testing etc -- but it seems to be generating the right system calls at the right times now.
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