Fix postmaster's handling of fork failure for a bgworker process.
authorTom Lane
Mon, 24 Apr 2017 16:16:58 +0000 (12:16 -0400)
committerTom Lane
Mon, 24 Apr 2017 16:16:58 +0000 (12:16 -0400)
commitdba1f310a564e8dc3496cd5ddec14ab6645ffd15
treec2e998e1bb3188a501c667177d2e062da7a4a42d
parent7be3678a8cfb55dcfca90fa586485f835ab912a5
Fix postmaster's handling of fork failure for a bgworker process.

This corner case didn't behave nicely at all: the postmaster would
(partially) update its state as though the process had started
successfully, and be quite confused thereafter.  Fix it to act
like the worker had crashed, instead.

In passing, refactor so that do_start_bgworker contains all the
state-change logic for bgworker launch, rather than just some of it.

Back-patch as far as 9.4.  9.3 contains similar logic, but it's just
enough different that I don't feel comfortable applying the patch
without more study; and the use of bgworkers in 9.3 was so small
that it doesn't seem worth the extra work.

transam/parallel.c is still entirely unprepared for the possibility
of bgworker startup failure, but that seems like material for a
separate patch.

Discussion: https://postgr.es/m/4905.1492813727@sss.pgh.pa.us
src/backend/postmaster/postmaster.c