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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Thomas Munro <thomas.munro@gmail.com>, Heikki Linnakangas <hlinnaka@iki.fi>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-10-14T23:14:35Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> On 2020-10-15 11:10:28 +1300, Thomas Munro wrote:
>> I don't think that's a problem -- the kernel will report the event to
>> each interested kqueue object.  The attached fixes the problem for me.

> Will it do so even if the kqueue is created after postmaster death?

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.

			regards, tom lane



Commits

  1. Handle EACCES errors from kevent() better.

  2. Make WL_POSTMASTER_DEATH level-triggered on kqueue builds.