Re: kevent latch paths don't handle postmaster death well

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: kevent latch paths don't handle postmaster death well
Date: 2020-10-15 05:42:01
Message-ID: CA+hUKGKhsCOmCKTn4__8QYggVpnAaRpMf07M8BfwE+HzOLozwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 15, 2020 at 12:55 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Thu, Oct 15, 2020 at 12:14 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > I did not try to test it, but there's code that purports to handle that
> > in latch.c, ~ line 1150, and the behavior it's expecting mostly agrees
> > with what I read in the macOS kevent man page. One thing I'd suggest
> > is that EACCES probably needs to be treated as "postmaster already dead",
> > too, in case the PID is now owned by another user ID.
>
> Good point. I'll push that change later today.

I tried to test this on my system but it seems like maybe FreeBSD
can't really report EACCES for EVFILT_PROC. From the man page and a
quick inspection of the source, you only have to be able to "see" the
process, and if you can't I think you'll get ESRCH, so EACCES may be
for other kinds of filters. I don't currently have any Apple gear to
hand, but its man page uses the same language, but on the other hand I
do see EACCES in filt_procattach() in the darwin-xnu sources on github
so I guess you can reach this case and get an ugly ereport (hopefully
followed swiftly by a proc_exit() from the next wait on one of the
long lived WESs, or a FATAL if this was the creation of one of those).
Fixed. Thanks!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2020-10-15 05:52:10 Re: Add Information during standby recovery conflicts
Previous Message Julien Rouhaud 2020-10-15 05:37:26 Re: Online checksums verification in the backend