Re: pgsql: Add kqueue(2) support to the WaitEventSet API.

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
Cc: Thomas Munro <tmunro(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgsql: Add kqueue(2) support to the WaitEventSet API.
Date: 2020-03-16 20:11:22
Message-ID: CA+hUKGKhAxJ8V8RVwCo6zJaeVrdOG1kFBHGZOOjf6DzW_omeMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Tue, Mar 17, 2020 at 12:55 AM Alexander Korotkov
<a(dot)korotkov(at)postgrespro(dot)ru> wrote:
> On Wed, Feb 5, 2020 at 7:59 AM Thomas Munro <tmunro(at)postgresql(dot)org> wrote:
> > Add kqueue(2) support to the WaitEventSet API.
> >
> > Use kevent(2) to wait for events on the BSD family of operating
> > systems and macOS. This is similar to the epoll(2) support added
> > for Linux by commit 98a64d0bd.
>
> I'm not sure if it was already reported in this thread (it seems to be
> not at the first glance), but I've discovered following issue on macos
> 10.13.6. If backend is under lldb and does XactLockTableWait(), then
> it does proc_exit(1).

/me digs out a Macintosh

Reproduced here. The problem seems to be that macOS's getppid()
returns the debugger's PID, while the debugger is attached. This
doesn't happen on FreeBSD (even though the debugger does internally
become the parent, getppid() is careful to return the "real" parent
PID so that user space doesn't notice this trickery; apparently Apple
made a different choice).

The getppid() check is there to close a vanishingly rare race
condition: when creating a WaitEventSet, we ask the kernel to tell us
when the postmaster exits, but there is a possibility that the
postmaster has already exited; normally that causes an error with
errno == ESRCH (no such PID, it's already gone), but another unrelated
process might have started that has the same PID, so we check if our
ppid has changed after a successful return code. That's not going to
work under a debugger on this OS.

Looking into some options.

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2020-03-16 20:30:40 Re: pgsql: Add kqueue(2) support to the WaitEventSet API.
Previous Message Alvaro Herrera 2020-03-16 19:29:25 pgsql: Plug memory leak

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2020-03-16 20:13:15 Re: Berserk Autovacuum (let's save next Mandrill)
Previous Message Laurenz Albe 2020-03-16 19:49:43 Re: Berserk Autovacuum (let's save next Mandrill)