From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Andres Freund <andres@anarazel.de>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process
Date: Fri, 16 Nov 2018 11:56:12 -0500
Message-ID: <29641.1542387372@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEepm=3BxOHw63Anwyx=pyy7Ju8cW6T0ZXNeKQS=WZp80hv_rg@mail.gmail.com>
References: <20180719.193054.155432744.horiguchi.kyotaro@lab.ntt.co.jp>
<CAEepm=1xcgQCEFHcDuks3CYEuCG+xnVLra3SDJB9xZbMc94WBw@mail.gmail.com>
<CAEepm=0=PkSXQ5oNU8BhY1DEzxw_EspsU14D_zAPnj+fBAjxFQ@mail.gmail.com>
<20180906.185715.126482377.horiguchi.kyotaro@lab.ntt.co.jp>
<CAEepm=3BxOHw63Anwyx=pyy7Ju8cW6T0ZXNeKQS=WZp80hv_rg@mail.gmail.com>
Thomas Munro <thomas.munro@enterprisedb.com> writes:
> [ 0001-Add-WL_EXIT_ON_PM_DEATH-pseudo-event-v4.patch ]
I took a quick look through this. I have no objection to the idea of
letting the latch infrastructure do the proc_exit(1), but I'm wondering
why this is in the thread that it's in. Is there any remaining connection
to the original complaint about BSDen not coping well with lots of
processes waiting on the same pipe?
A couple minor code gripes:
- rc = WaitLatch(MyLatch,
- WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
- (nap.tv_sec * 1000L) + (nap.tv_usec / 1000L),
- WAIT_EVENT_AUTOVACUUM_MAIN);
+ WaitLatch(MyLatch,
+ WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
+ (nap.tv_sec * 1000L) + (nap.tv_usec / 1000L),
+ WAIT_EVENT_AUTOVACUUM_MAIN);
I'd advise making the code in places like this look like
(void) WaitLatch(MyLatch, ...);
Otherwise, you are likely to draw complaints about "return value is
sometimes ignored" from Coverity and other static analyzers. The
(void) cast makes it explicit that you're intentionally ignoring
the result value in this one place.
@@ -1021,6 +1051,19 @@ WaitEventSetWait(WaitEventSet *set, long timeout,
pgstat_report_wait_end();
+ /*
+ * Exit immediately if the postmaster died and the caller asked for
+ * automatic exit in that case.
+ */
+ if (set->exit_on_postmaster_death)
+ {
+ for (i = 0; i < returned_events; ++i)
+ {
+ if (occurred_events[i].events == WL_POSTMASTER_DEATH)
+ proc_exit(1);
+ }
+ }
+
return returned_events;
}
Since exit_on_postmaster_death = true is going to be the normal case,
it seems a bit unfortunate that we have to incur this looping every time
we go through WaitEventSetWait. Can't we put the handling of this in some
spot where it only gets executed when we've detected WL_POSTMASTER_DEATH,
like right after the PostmasterIsAliveInternal calls?
if (!PostmasterIsAliveInternal())
{
+ if (set->exit_on_postmaster_death)
+ proc_exit(1);
occurred_events->fd = PGINVALID_SOCKET;
occurred_events->events = WL_POSTMASTER_DEATH;
occurred_events++;
returned_events++;
}
regards, tom lane
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: tgl@sss.pgh.pa.us, thomas.munro@enterprisedb.com, horiguchi.kyotaro@lab.ntt.co.jp, hlinnaka@iki.fi, andres@anarazel.de
Subject: Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process
In-Reply-To: <29641.1542387372@sss.pgh.pa.us>
References: <20180719.193054.155432744.horiguchi.kyotaro@lab.ntt.co.jp> <CAEepm=1xcgQCEFHcDuks3CYEuCG+xnVLra3SDJB9xZbMc94WBw@mail.gmail.com> <CAEepm=0=PkSXQ5oNU8BhY1DEzxw_EspsU14D_zAPnj+fBAjxFQ@mail.gmail.com> <20180906.185715.126482377.horiguchi.kyotaro@lab.ntt.co.jp> <CAEepm=3BxOHw63Anwyx=pyy7Ju8cW6T0ZXNeKQS=WZp80hv_rg@mail.gmail.com> <29641.1542387372@sss.pgh.pa.us>
* 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