Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andres Freund <andres(at)anarazel(dot)de>, Marco Pfatschbacher <Marco_Pfatschbacher(at)genua(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process
Date: 2018-07-19 11:51:46
Message-ID: CAEepm=1xcgQCEFHcDuks3CYEuCG+xnVLra3SDJB9xZbMc94WBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 19, 2018 at 10:30 PM, Kyotaro HORIGUCHI
<horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
>> Hmm. Why wait any longer? The cluster is broken. Is there some
>> correctness reason to defer shutdown in any of these places?
>
> Well, please don't get me wrong. I don't object to backends' exit
> on postmaster death, rather I'm for it. Maybe the idea of mine
> came from somthing like this (perhaps newer one), in the meaning
> of just why it is working in that way now.
>
> https://www.postgresql.org/message-id/21877.1294946166@sss.pgh.pa.us

Thanks, that was interesting. It's from *before* the pipe solution
was implemented though so I'm not sure it's relevant: the
exit-as-soon-as-possible camp won that battle, we just missed a few
places.

>> He mentioned that syslogger.c is a special case. In my patch I added
>> WL_EXIT_ON_PM_DEATH to SysLoggerMain()'s WaitLatch*() calls, because I
>> have to or the new assertion fails. Hmm, yeah, that's not great
>> because it might discard the last words of other backends. So here is
>> a new version that treats syslogger.c specially and may have other
>> performance benefits.
>
> Yeah. That seems good. Couldn't we reuse prepared WaitEventSet in
> other places? For example PgstatCollectorMain has the same
> characteristics, where WaitLatchOrSocket is used with fixed
> parameters and waiting on a socket which gets frequent receipts.

+1, but I'm considering that to be a separate project, or I'll never
get this patch committed. It may be possible to have a small number
of them reused in many places, and it may be possible for
WaitLatchXXX() to reuse them automatically (so we don't have to change
every call site).

> # Is it intentional that the patch doesn't touch pgstat.c?

Yes. pgstat.c still uses WL_POSTMASTER_DEATH because it does
something special: it calls pgstat_write_statsfiles() before it exits.

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Quan TRAN 2018-07-19 12:12:40 Re: Segfault logical replication PG 10.4
Previous Message Alexander Korotkov 2018-07-19 11:43:19 Re: Bug in gin insert redo code path during re-compression of empty gin data leaf pages