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

From: "Jelte Fennema-Nio" <postgres(at)jeltef(dot)nl>
To: "Peter Eisentraut" <peter(at)eisentraut(dot)org>
Cc: "Heikki Linnakangas" <hlinnaka(at)iki(dot)fi>, "PostgreSQL Hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Alvaro Herrera" <alvherre(at)alvh(dot)no-ip(dot)org>, "Jacob Champion" <jacob(dot)champion(at)enterprisedb(dot)com>
Subject: Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore
Date: 2026-11-26 11:55:40
Message-ID: DN54G3VEOJ2G.283CLYWBZOFVM@jeltef.nl
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu Nov 26, 2026 at 9:44 AM CET, Peter Eisentraut wrote:
> Feedback on patch [PATCH v13 3/5] fe_utils: Simplify cancel logic in
> wait_on_slots:

Addressed all of this in the attached v14.

> 2) The new code loses the message "Cancel request sent" under some
> circumstances.

I fixed this by not calling SetCancelConn at all anymore for parallel
slots. Instead it now relies on the cancel being sent by
disconnectDatabase, and prints a user message in ParallelSlotsTerminate.

> But actually shouldn't the header file be in src/include/port/ (or maybe
> src/include/port/win32/)?

That's totally correct and indeed simplifies the final patch. I moved it
to src/include/port now. Moving it to src/include/port/win32/pthread.h
might change MinGW behaviour in ways that I'm not sure are better since
it has its own pthread (similarly for src/include/port/win32_msvc).
Since hopefully we'll get rid of this thing once we get Thomas's
pg_threads.h, I don't feel like spending too much time on this.

Attachment Content-Type Size
v14-0001-fe_utils-Stop-using-SetCancelConn-for-parallel-s.patch text/x-patch 7.7 KB
v14-0002-Move-Windows-pthread-compatibility-functions-to-.patch text/x-patch 7.3 KB
v14-0003-Don-t-use-deprecated-and-insecure-PQcancel-psql-.patch text/x-patch 40.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2026-11-26 12:13:32 Re: Unify parallel worker handling for index builds and instrumentation
Previous Message Daniel Gustafsson 2026-11-26 11:42:18 Re: [DOC][PATCH] Improving the HTML layout of release notes