Jacob Champion <pchamp...@vmware.com> writes: > On Thu, 2022-01-13 at 14:51 +0000, Jelte Fennema wrote: >> 2. Cancel connections benefit automatically from any improvements made >> to the normal connection establishment codepath. Examples of things >> that it currently gets for free currently are TLS support and >> keepalive settings.
> This seems like a big change compared to PQcancel(); one that's not > really hinted at elsewhere. Having the async version of an API open up > a completely different code path with new features is pretty surprising > to me. Well, the patch lacks any user-facing doco at all, so a-fortiori this point is not covered. I trust the plan was to write docs later. I kind of feel that this patch is going in the wrong direction. I do see the need for a version of PQcancel that can encrypt the transmitted cancel request (and yes, that should work on the backend side; see recursion in ProcessStartupPacket). I have not seen requests for a non-blocking version, and this doesn't surprise me. I feel that the whole non-blocking aspect of libpq probably belongs to another era when people didn't trust threads. So what I'd do is make a version that just takes a PGconn, sends the cancel request, and returns success or failure; never mind the non-blocking aspect. One possible long-run advantage of this is that it might be possible to "sync" the cancel request so that we know, or at least can find out afterwards, exactly which query got cancelled; something that's fundamentally impossible if the cancel function works from a clone data structure that is disconnected from the current connection state. (Note that it probably makes sense to make a clone PGconn to pass to fe-connect.c, internally to this function. I just don't want to expose that to the app.) regards, tom lane