postgresql/src
Tom Lane 3887e9455f 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
2019-10-07 12:39:09 -04:00
..
backend Check for too many postmaster children before spawning a bgworker. 2019-10-07 12:39:09 -04:00
bin Hack pg_ctl to report postmaster's exit status. 2019-10-07 10:39:07 -04:00
common Optimize partial TOAST decompression 2019-10-01 14:28:28 +02:00
fe_utils Split out recovery confing-writing code from pg_basebackup 2019-09-25 14:35:24 -03:00
include Simplify PGAC_STRUCT_TIMEZONE Autoconf macro 2019-10-07 16:47:23 +02:00
interfaces Remove use of deprecated Autoconf define 2019-10-07 16:47:23 +02:00
makefiles Remove support for non-ELF BSD systems 2019-07-01 23:56:20 +01:00
pl Simplify PGAC_STRUCT_TIMEZONE Autoconf macro 2019-10-07 16:47:23 +02:00
port Use explicit_bzero 2019-09-05 08:30:42 +02:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Report test_atomic_ops() failures consistently, via macros. 2019-10-05 10:05:05 -07:00
timezone Update time zone data files to tzdata release 2019c. 2019-09-20 19:53:33 -04:00
tools Fix incorrect use of term HEAD for Git 2019-10-07 09:44:17 +02:00
tutorial Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Don't disable ccache when building with coverage support 2019-09-24 10:00:56 +02:00
Makefile.shlib Remove support for non-ELF BSD systems 2019-07-01 23:56:20 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00