Re: psql not responding to SIGINT upon db reconnection
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Tristan Partin <tristan@neon.tech>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@postgresql.org,
Shlok Kyal <shlok.kyal.oss@gmail.com>
Date: 2023-11-22T21:00:03Z
Lists: pgsql-hackers
On 22/11/2023 19:29, Tristan Partin wrote: > On Thu Nov 16, 2023 at 8:33 AM CST, Heikki Linnakangas wrote: >> On 06/11/2023 19:16, Tristan Partin wrote: >>>>> That sounds like a much better solution. Attached you will find a v4 >>>>> that implements your suggestion. Please let me know if there is >>>>> something that I missed. I can confirm that the patch works. >> >> This patch is missing a select(). It will busy loop until the connection >> is established or cancelled. > > If I add a wait (select, poll, etc.), then I can't control-C during the > blocking call, so it doesn't really solve the problem. Hmm, they should return with EINTR on signal. At least on Linux; I'm not sure how portable that is. See signal(7) man page, section "Interruption of system calls and library functions by signal handlers". You could also use a timeout like 5 s to ensure that you wake up and notice that the signal was received eventually, even if it doesn't interrupt the blocking call. -- Heikki Linnakangas Neon (https://neon.tech)
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix old, misleading comment for PGRES_POLLING_ACTIVE.
- e57fe3824ee7 17.0 landed
-
Remove reachable call to pg_unreachable().
- 12b964d7815b 17.0 landed
-
Allow SIGINT to cancel psql database reconnections.
- cafe1056558f 17.0 landed
-
Expose PQsocketPoll via libpq
- f5e4dedfa81f 17.0 landed
-
Fix query cancellation handling in psql
- 5d43c3c54d77 13.0 cited