Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process
Thomas Munro <thomas.munro@enterprisedb.com>
From: Thomas Munro <thomas.munro@enterprisedb.com>
To: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>, Andres Freund <andres@anarazel.de>, Marco Pfatschbacher <Marco_Pfatschbacher@genua.de>,
Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2018-07-19T11:51:46Z
Lists: pgsql-hackers
On Thu, Jul 19, 2018 at 10:30 PM, Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.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
Commits
-
Add WL_EXIT_ON_PM_DEATH pseudo-event.
- cfdf4dc4fc96 12.0 landed
-
Use signals for postmaster death on Linux.
- 9f09529952ac 12.0 landed