On Fri, Feb 21, 2025 at 9:19 AM Andres Freund <andres@anarazel.de> wrote:
> I don't think we can generally rely on all blocking system calls to be
> interruptible by signals on all platforms?
Probably not; I wasn't sure how much detail to put in here after "must
remain interruptible."
> And, probably worse, isn't relying on getting EINTR rather racy, due to the
> chance of the signal arriving between CHECK_FOR_INTERRUPTS() and the blocking
> system call?
That is worse, and to be honest I hadn't ever thought about that race
condition before your email. So wait... how do people actually rely on
EINTR in production-grade client software? pselect/ppoll exist,
clearly, but they're used so rarely IME. (Have we all just been
subconsciously trained to mash Ctrl-C until the program finally stops?
I'm honestly kind of horrified by this revelation.)
Anyway, yes, this documentation clearly needs to be strengthened.
> Is it a good idea to support that? We e.g. rely on libpq connections made by
> the backend to be interruptible. Admittedly that's, I think, already not
> bulletproof, due to libpq's DNS lookups going through libc if connection
> string contains a name that needs to be looked up, but this seems to make that
> a bit worse?
A bit. The same for Kerberos, IIRC. Is the current configure warning
not strong enough to imply that the packager is on shaky ground? (I
patterned that off of the LDAP crash warning, which seemed much worse
to me. :D)
We can always declare non-support, I suppose, but anyone who doesn't
care about that problem (say, because they just want to use
single-connection psql) is then stuck hacking around it.
--Jacob