On Fri, Nov 12, 2021 at 9:24 AM Robert Haas <robertmh...@gmail.com> wrote: > On Thu, Nov 11, 2021 at 2:50 PM Andres Freund <and...@anarazel.de> wrote: > > They can count, but only when used for network sockets or pipes ("slow > > devices" or whatever the posix language is). Disk IO doesn't count as that. > > So > > I don't think it'd be a huge issue. > > Somehow the idea that the network is a slow device and the disk a fast > one does not seem like it's necessarily accurate on modern hardware, > but I guess the spec is what it is.
[Somehow I managed to reply to Robert only; let me try that again, this time to the list...] Network filesystems have in the past been confusing because they're both disk-like and network-like, and also slow as !@#$, which is why there have been mount point options like "intr", "nointr" (now ignored on Linux) to control what happens if you receive an async signal during a sleepy read/write. But even if you had some kind of Deathstation 9000 that had a switch on the front panel that ignores SA_RESTART and produces EINTR for disk I/O when a signal arrives, PostgreSQL already doesn't work today. Our pread() and pwrite() paths for data and WAL don't not have a EINTR loops or CHECK_FOR_INTERRUPTS() (we just can't take interrupts in the middle of eg a synchronous write), so I think we'd produce an ERROR or PANIC. So I think disk I/O is irrelevant, and network/pipe I/O is already handled everywhere via latch.c facilities. If there are any eg blocking reads on a socket in PostgreSQL, we should fix that to use latch.c non-blocking techniques, because such a place is already a place that ignores postmaster death and interrupts. To be more precise: such a place could of course wake up for EINTR on SIGUSR1 from procsignal.c, and that would no longer happen with my patch, but if we're relying on that anywhere, it's dangerous and unreliable. If SIGUSR1 is delivered right before you enter a blocking read(), you'll sleep waiting for the socket or whatever. That's precisely the problem that latch.c solves, and why it's already a bug if there are such places.