3 ms·
It appears to be a PostgreSQL bug from my reading. The return code causing the problem has always been legitimate, even though you never expected to see it in p
by jandrewrogers 6y ago
It appears to be a PostgreSQL bug from my reading. The return code causing the problem has always been legitimate, even though you never expected to see it in practice.
I did a quick check of the source of two other storage engines that run on both Linux and macOS to see how common this oversight is. They both had code for handling this case correctly for years. It was probably never used, but it was implemented because the syscall docs allowed for the possibility.
This is the kind of thing I would have assumed PostgreSQL handles correctly as a matter of pedantry. Given how syscall heavy PostgreSQL is, it will be a fair amount of work to fix it.
- jorams 6y agoWhile open[1] is documented for macOS to be able to return EINTR, the documentation for sigaction[2] seems to specify (in confusing wording) that setting SA_RESTART prevents that. It seems to me like a bug in macOS, since they're going against their own documentation. [1]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/open.2.html#//apple_ref/doc/man/2/open https://developer.apple.com/library/archive/documentation/Sy... [2]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sigaction.2.html https://developer.apple.com/library/archive/documentation/Sy... specifically: > If a signal is caught during the system calls listed below, the call may be forced to terminate with the error EINTR, the call may return with a data transfer shorter than requested, or the call may be restarted. Restart of pending calls is requested by setting the SA_RESTART bit in sa_flags. The affected system calls include open(2), read(2), write(2), sendto(2), recvfrom(2), sendmsg(2) and recvmsg(2) on a communications channel or a slow device (such as a terminal, but not a regular file) and during a wait(2) or ioctl(2). However, calls that have already committed are not restarted, but instead return a partial success (for example, a short read count).
- fanf2 6y agoThe Apple documentation matches POSIX so if open() is returning EINTR for reasons other than a signal, that is a standards conformance bug.