On 2015-12-25 13:28:55 -0500, Tom Lane wrote:
> Hmm. And all those FDs point to the same pipe. I wonder if we're looking
> at contention for some pipe-related data structure inside the kernel.
Sounds fairly likely - and not too surprising. In this scenario we've a
couple 100k registrations/unregistrations to a pretty fundamentally
shared resource (the wait queue for changes to the pipe). Not that
surprising that it becomes a problem.
There's a couple solutions I can think of to that problem:
1) Use epoll()/kqueue, or other similar interfaces that don't require re-registering fds at every invocation. My guess
isthat that'd be desirable for performance anyway.
2) Create a pair of fds between postmaster/backend for each backend. While obviously increasing the the number of FDs
noticeably, it's interesting for other features as well: If we ever want to do FD passing from postmaster to existing
backends,we're going to need that anyway.
3) Replace the postmaster_alive_fds socketpair by some other signalling mechanism. E.g. sending a procsignal to each
backend,which sets the latch and a special flag in the latch structure.
Andres