Hacker News new | ask | show | jobs
by efxhoy 1859 days ago
> Automatic cancellation of long-running queries if the client disconnects

Sweet! I often screw up a query and need to cancel it with

  pg_cancel_backend(pid)
because Ctrl-C rarely works. With this I can just ragequit and reconnect. Sweet!
1 comments

I agree this is a great addition, but FWIW it isn't normal for ^C to not work in psql. Perhaps you are using some other client that doesn't support aborting queries properly, or have something on the network between you and the server behaving poorly and dropping connections?
It's psql through an ssh-tunnel to RDS on AWS, postgres 10.6 usually. But I've had the same experience on other versions and locally too.

The problem usually isn't that it doesn't work ever, just that it can take a very long time, especially if the query is reading some crazy amount of data. I've always found pg_cancel_backend() to be almost instant though.

Sounds like it's ^C on a client that doesn't trap SIGTERM and cleanup. Probably something they're working on.