From: Andres Freund <andres@anarazel.de>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Marco Pfatschbacher <Marco_Pfatschbacher@genua.de>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process
Date: Tue, 10 Apr 2018 17:26:43 -0700
Message-ID: <20180411002643.6buofht4ranhei7k@alap3.anarazel.de> (raw)
In-Reply-To: <CAEepm=2g-tf8Cmh2mcCObr=yLHujcBWXLjqHijp_+0M-krsiag@mail.gmail.com>
References: <20160915135755.GC19008@genua.de>
<20160915192616.f2yq4wtltnlhjw3h@alap3.anarazel.de>
<20160916075547.GC15576@genua.de>
<20160916182339.2qe2bj3zgk6zfkgk@alap3.anarazel.de>
<CAEepm=3FW33PeRxt0jE4N0truJqOepp72R6W-zyM5mu1bxnZRw@mail.gmail.com>
<20160919232606.jdhup2qsrgnjq4xc@alap3.anarazel.de>
<CAEepm=1TCviRykkUb69ppWLr_V697rzd1j3eZsRMmbXvETfqbQ@mail.gmail.com>
<20180411000327.7t4r7bckeqyo3jju@alap3.anarazel.de>
<CAEepm=2g-tf8Cmh2mcCObr=yLHujcBWXLjqHijp_+0M-krsiag@mail.gmail.com>
Hi,
On 2018-04-11 12:17:14 +1200, Thomas Munro wrote:
> I arrived at this idea via the realisation that the closest thing to
> prctl(PR_SET_PDEATHSIG) on BSD-family systems today is
> please-tell-my-kqueue-if-this-process-dies. It so happens that my
> kqueue patch already uses that instead of the pipe to detect
> postmaster death. The only problem is that you have to ask it, by
> calling it kevent(). In a busy loop like those two, where there is no
> other kind of waiting going on, you could do that by calling kevent()
> with timeout = 0 to check the queue.
Which is not cheap.
> You could probably figure out a way to hide the
> prctl(PR_SET_PDEATHSIG)-based approach inside the WaitEventSet code,
> with a fast path that doesn't make any system calls if the only event
> registered is postmaster death (you can just check the global variable
> set by your signal handler). But I guess you wouldn't like the extra
> function call so I guess you'd prefer to check the global variable
> directly in the busy loop, in builds that have
> prctl(PR_SET_PDEATHSIG).
Yea, I'd really want this to be a inline function of the style
static inline bool
PostmasterIsAlive(void)
{
if (!postmaster_possibly_dead)
return true;
return PostmasterIsAliveInternal();
}
I do not like the WES alternative because a special cased "just
postmaster death" WES seems to have absolutely no advantage over a
faster PostmasterIsAlive(). And using WES seems to make a cheap check
like the above significantly more complicated.
Greetings,
Andres Freund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: andres@anarazel.de, thomas.munro@enterprisedb.com, Marco_Pfatschbacher@genua.de
Subject: Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process
In-Reply-To: <20180411002643.6buofht4ranhei7k@alap3.anarazel.de>
References: <20160915135755.GC19008@genua.de> <20160915192616.f2yq4wtltnlhjw3h@alap3.anarazel.de> <20160916075547.GC15576@genua.de> <20160916182339.2qe2bj3zgk6zfkgk@alap3.anarazel.de> <CAEepm=3FW33PeRxt0jE4N0truJqOepp72R6W-zyM5mu1bxnZRw@mail.gmail.com> <20160919232606.jdhup2qsrgnjq4xc@alap3.anarazel.de> <CAEepm=1TCviRykkUb69ppWLr_V697rzd1j3eZsRMmbXvETfqbQ@mail.gmail.com> <20180411000327.7t4r7bckeqyo3jju@alap3.anarazel.de> <CAEepm=2g-tf8Cmh2mcCObr=yLHujcBWXLjqHijp_+0M-krsiag@mail.gmail.com> <20180411002643.6buofht4ranhei7k@alap3.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox