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

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, 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-12-01 01:32:25
Message-ID: CAGRkXqT0k7OcjbMWnt-0fJ8a5iEEVGRXgHQV-ju3j5DvPoGSXA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Jelte,

Thanks for working on this. I tested v14 and saw that Ctrl-C in
pg_restore can leave the next command running on the server.

I restored a dump with two slow materialized views on macOS and sent
SIGINT during the REFRESH of mv1. With v14, in 8 of 10 runs the REFRESH
of mv2 was still running after pg_restore had exited. On master it was
0 of 10. This is one of the v14 runs.

pg_restore: error: could not execute query: ERROR: canceling statement
due to user request
CONTEXT: SQL function "f" statement 1
Command was: REFRESH MATERIALIZED VIEW public.mv1;

pg_restore: terminated by user

I think it is because the signal handler on master kept the main thread
stopped until _exit(). Now only the cancel thread waits, so the main
thread can get the error and send the next command before the process
exits.

Thanks,
Shihao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2026-12-01 01:37:30 Re: Row pattern recognition
Previous Message shihao zhong 2026-12-01 01:21:46 hashname() ignores nondeterministic collations