Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Marco Pfatschbacher <Marco_Pfatschbacher(at)genua(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process
Date: 2017-12-04 21:57:34
Message-ID: CAEepm=0qQ6DO-u=25ny5EJAUbWeHbAQgJj1UJFAL1NWJNxC+gg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 5, 2017 at 5:55 AM, Marco Pfatschbacher
<Marco_Pfatschbacher(at)genua(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-12-04 22:17:21 Re: Errands around AllocateDir()
Previous Message Peter Geoghegan 2017-12-04 21:31:44 Re: Do we actually need an ItemId array on nbtree pages containing fixed-width tuples?