Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore
Date
Msg-id de93d338-fc4d-4184-856a-b2c19eca0499@iki.fi
Whole thread
In response to Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore  ("Jelte Fennema-Nio" <postgres@jeltef.nl>)
Responses Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore
List 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




pgsql-hackers by date:

Previous
From: Zsolt Parragi
Date:
Subject: Re: File locks for data directory lockfile in the context of Linux namespaces
Next
From: Mario González Troncoso
Date:
Subject: Re: Possible replace of strncpy on xactdesc.c