Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Jelte Fennema-Nio <postgres@jeltef.nl>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Jacob Champion <jacob.champion@enterprisedb.com>
Date: 2026-07-06T22:12:57Z
Lists: pgsql-hackers
On 04/07/2026 01:28, Jelte Fennema-Nio wrote:
> On Tue, 7 Apr 2026 at 02:18, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>> The cancel handling in wait_on_slots() in parallel_slot.c is surprising
>> in a different way. It already uses async libpq calls and has a select()
>> loop, but it still relies on the signal handler to do the cancellation.
>> And it arbitrarily PQcancel()s only one of the connections it waits on.
> 
> Addressed this in 0002

This relies on the signal to interrupt select(), but I'm afraid that's 
not guaranteed on all platforms. Also, there's a race condition if the 
signal arrives *just* before you call select(). That's what the 
"self-pipe hack" is for, see comments at waiteventset.c.

- Heikki