pgsql: Block signals earlier during postmaster startup. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Block signals earlier during postmaster startup.
Date
Msg-id E1WWYtU-0005bu-09@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Block signals earlier during postmaster startup.

Formerly, we set up the postmaster's signal handling only when we were
about to start launching subprocesses.  This is a bad idea though, as
it means that for example a SIGINT arriving before that will kill the
postmaster instantly, perhaps leaving lockfiles, socket files, shared
memory, etc laying about.  We'd rather that such a signal caused orderly
postmaster termination including releasing of those resources.  A simple
fix is to move the PostmasterMain stanza that initializes signal handling
to an earlier point, before we've created any such resources.  Then, an
early-arriving signal will be blocked until we're ready to deal with it
in the usual way.  (The only part that really needs to be moved up is
blocking of signals, but it seems best to keep the signal handler
installation calls together with that; for one thing this ensures the
kernel won't drop any signals we wished to get.  The handlers won't get
invoked in any case until we unblock signals in ServerLoop.)

Per a report from MauMau.  He proposed changing the way "pg_ctl stop"
works to deal with this, but that'd just be masking one symptom not
fixing the core issue.

It's been like this since forever, so back-patch to all supported branches.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/5d8117e1f38d7240e99d57e624a9d880872c7e98

Modified Files
--------------
src/backend/postmaster/postmaster.c |   60 +++++++++++++++++------------------
1 file changed, 30 insertions(+), 30 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Block signals earlier during postmaster startup.
Next
From: Tom Lane
Date:
Subject: pgsql: Improve contrib/pg_trgm's heuristics for regexp index searches.