Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process
Date
Msg-id CAEepm=0qQ6DO-u=25ny5EJAUbWeHbAQgJj1UJFAL1NWJNxC+gg@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process  (Marco Pfatschbacher <Marco_Pfatschbacher@genua.de>)
List pgsql-hackers
On Tue, Dec 5, 2017 at 5:55 AM, Marco Pfatschbacher
<Marco_Pfatschbacher@genua.de> wrote:
> On Thu, Sep 15, 2016 at 04:40:00PM -0400, Tom Lane wrote:
>> I just noticed that kqueue appears to offer a solution to this problem,
>> ie one of the things you can wait for is exit of another process (named
>> by PID, looks like).  If that's portable to all kqueue platforms, then
>> integrating a substitute for the postmaster death pipe might push that
>> patch over the hump to being a net win.
>
> kqueue does indeed support EVFILT_PROC like you said.
> But using this effectively, would need a separate monitoring process,
> because we cannot use poll(2) and kevent(2) together within the same loop.

FWIW the kqueue patch I posted uses EVFILT_PROC as Tom suggested and
it works fine according to my testing (FreeBSD +macOS).  With that
patch, there is no poll, just kqueue everywhere.

> But how about this:
> We just use getppid to see whether the process id of our parent
> has changed to 1 (init).
> Just like calling read on the pipe, that's just one systemcall.

I'm still not sure why we have to make any system calls at all.  Do we
not trust WaitLatch() to tell us about WL_POSTMASTER_DEATH reliably,
or is it that we don't trust it to tell us about that event when there
are other events happening due to priorities, or...?

-- 
Thomas Munro
http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Do we actually need an ItemId array on nbtree pages containingfixed-width tuples?
Next
From: Tom Lane
Date:
Subject: Re: Errands around AllocateDir()