pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't run atexit callbacks during signal exits from ProcessStart
Date: Fri, 11 Sep 2020 16:24:53 +0000
Message-ID: <E1kGlr3-0003y6-Rx@gemulon.postgresql.org> (raw)

Don't run atexit callbacks during signal exits from ProcessStartupPacket.

Although 58c6feccf fixed the case for SIGQUIT, we were still calling
proc_exit() from signal handlers for SIGTERM and timeout failures in
ProcessStartupPacket.  Fortunately, at the point where that code runs,
we haven't yet connected to shared memory in any meaningful way, so
there is nothing we need to undo in shared memory.  This means it
should be safe to use _exit(1) here, ie, not run any atexit handlers
but also inform the postmaster that it's not a crash exit.

To make sure nobody breaks the "nothing to undo" expectation, add
a cross-check that no on-shmem-exit or before-shmem-exit handlers
have been registered yet when we finish using these signal handlers.

This change is simple enough that maybe it could be back-patched,
but I won't risk that right now.

Discussion: https://postgr.es/m/1850884.1599601164@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6693a96b329ec46f1df916f2a28d640cc9a9977d

Modified Files
--------------
src/backend/postmaster/postmaster.c | 72 +++++++++++++++++--------------------
src/backend/storage/ipc/ipc.c       | 17 +++++++++
src/include/storage/ipc.h           |  1 +
3 files changed, 51 insertions(+), 39 deletions(-)



Message-ID: <E1kGlr3-0003y6-Rx@gemulon.postgresql.org>
Permalink:  ../E1kGlr3-0003y6-Rx@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kGlr3-0003y6-Rx@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Don't run atexit callbacks during signal exits from ProcessStart
  In-Reply-To: <E1kGlr3-0003y6-Rx@gemulon.postgresql.org>
  References: <E1kGlr3-0003y6-Rx@gemulon.postgresql.org>

* 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