pgsql: Fix postmaster's handling of fork failure for a bgworker process

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix postmaster's handling of fork failure for a bgworker process
Date: 2017-04-24 16:17:16
Message-ID: E1d2gfs-0004v0-SS@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4fe04244b584749351657e99f3e6e1436e9b65a8

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

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2017-04-24 16:32:03 pgsql: Get rid of extern declarations of non-existent functions.
Previous Message Tom Lane 2017-04-24 15:15:21 pgsql: Code review for commands/statscmds.c.