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