model-writtenrun 8452 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Jelte Fennema-Nio proposed replacing unencrypted PQcancel requests in frontend tools with the newer cancellation APIs, using a dedicated thread because those APIs are not signal-safe; he raised possible PostgreSQL 17–18 backports and deferred converting Unix pg_dump workers to threads as separate work #1.
- Jelte separated the fe_utils and pg_dump changes for easier review and made signal-handler writes to their wakeup pipes nonblocking #3.
- Heikki Linnakangas requested an explanation of the independent cancellation mechanisms and identified the risk of a delayed cancellation reaching a later query #4; Jelte added extensive comments while declining generic multiple-connection support as scope expansion #5.
- Heikki suggested capturing the connection generation in the signal handler and testing slow cancellation connections #6; Jelte supplied generation-check and pipe-draining fixups, alongside a separate experimental approach using nonblocking frontend APIs #7 #8.
- Jelte then adopted a simpler synchronization rule: replacing or clearing the cancel connection must wait for an in-flight cancellation to finish, preserving existing behavior under network delays; he reported testing this by dropping new connections while allowing the query connection to continue #9.
- Heikki supported that direction but questioned which thread receives SIGINT #10; Jelte blocked SIGINT in the cancellation thread to protect psql's main-thread longjmp callbacks, tested delivery to individual threads, and rejected aborting an in-flight cancellation because it could still reach a subsequent query #11.
- Heikki's broader review highlighted confusing COPY callback ordering, redundant psql cancellation flags, arbitrary single-connection cancellation in parallel-slot waits, and duplicated pipe infrastructure, while exploring more substantial asynchronous and libpq alternatives #12.
- After the gap, Jelte substantially reworked the series with two preparatory cleanups and shared cancellation infrastructure for fe_utils and pg_dump, including separate signal and thread callbacks; Unix worker threads and a new libpq cancellation facility remained outside the series #13.
- Heikki considered the psql flag cleanup sound but moved existing single-step prompt problems to separate discussion #14, while Zsolt Parragi requested documentation or a guard against repeated setup_cancel_handler calls, with no resolution shown in this thread #15.
- Heikki extracted Jelte's overview into a patch describing existing behavior #16, received Jelte's confirmation #17, and committed it unchanged as cde6ede713 before posting the rebased remainder #18.
- Heikki found that the parallel-slot cleanup could miss cancellation between checking the flag and entering select #19; Michael Paquier separately explained that his historical concern about merging psql's cancellation flags involved failed cancellation requests and had since been addressed #20.
- Jelte initially addressed the select race with one-second polling on all platforms #21; Heikki proposed alternatives that avoided polling #22, and Jelte initially favored uniform cross-platform behavior #23 before implementing pselect with a timed-select fallback in the submission that also rebased over the removal of TerminateThread #24.
- Anthonin Bonnefoy's testing found that printing the cancellation message before sending the request could race with the less pager's repaint #25; Jelte restored the previous message timing after successful cancellation #26.
- In September, Jelte rebased the remaining series, explicitly confirmed his choice of pselect, and requested that at least the preparatory psql cleanup be committed because it repeatedly needed rebasing #27.
- Peter Eisentraut subsequently found that the psql cleanup changes Ctrl-C during COPY input in a script from continuing the script successfully to aborting it with exit code 3, and requested an intentional, separately considered behavior change #28; Alvaro Herrera opposed propagating command cancellation into quitting psql #29.
- Jelte agreed that continuing a script after Ctrl-C at an input prompt was a bug and posted a five-patch series with an explicit preparatory fix setting cancel_pressed before longjmp, followed by the flag cleanup and existing cancellation work #30.
- Responding to Alvaro's objection, Jelte clarified that interactive psql behavior remains unchanged and argued that Ctrl-C should terminate a noninteractive script even while it is waiting for user input #31.
- Peter committed the standalone script-mode Ctrl-C fix from #30 unchanged as 8b529705d1 and announced that he would continue reviewing the remaining patches #32.
- Peter then committed the psql flag cleanup from #30 as 5aa40dc679, with minor comment and unused-include cleanup, and announced its completion in #33.
- At the last message, the cancellation overview, script-mode Ctrl-C fix, and psql flag cleanup have landed; the parallel-slot cancellation cleanup, Windows pthread relocation, and replacement of deprecated PQcancel calls from #30 remain pending #33.