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: Check for too many postmaster children before spawning a bgworke
Date: Mon, 07 Oct 2019 16:39:32 +0000
Message-ID: <E1iHW2m-0004bD-5u@gemulon.postgresql.org> (raw)

Check for too many postmaster children before spawning a bgworker.

The postmaster's code path for spawning a bgworker neglected to check
whether we already have the max number of live child processes.  That's
a bit hard to hit, since it would necessarily be a transient condition;
but if we do, AssignPostmasterChildSlot() fails causing a postmaster
crash, as seen in a report from Bhargav Kamineni.

To fix, invoke canAcceptConnections() in the bgworker code path, as we
do in the other code paths that spawn children.  Since we don't want
the same pmState tests in this case, add a child-process-type parameter
to canAcceptConnections() so that it can know what to do.

Back-patch to 9.5.  In principle the same hazard exists in 9.4, but the
code is enough different that this patch wouldn't quite fix it there.
Given the tiny usage of bgworkers in that branch it doesn't seem worth
creating a variant patch for it.

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

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/021065aac676c96b703b9c7a02da763469a183c1

Modified Files
--------------
src/backend/postmaster/postmaster.c | 46 ++++++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 13 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1iHW2m-0004bD-5u@gemulon.postgresql.org>
Permalink:  ../E1iHW2m-0004bD-5u@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iHW2m-0004bD-5u@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: Check for too many postmaster children before spawning a bgworke
  In-Reply-To: <E1iHW2m-0004bD-5u@gemulon.postgresql.org>
  References: <E1iHW2m-0004bD-5u@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