postgresql/src/backend
Robert Haas 28724fd90d Report failure to start a background worker.
When a worker is flagged as BGW_NEVER_RESTART and we fail to start it,
or if it is not marked BGW_NEVER_RESTART but is terminated before
startup succeeds, what BgwHandleStatus should be reported?  The
previous code really hadn't considered this possibility (as indicated
by the comments which ignore it completely) and would typically return
BGWH_NOT_YET_STARTED, but that's not a good answer, because then
there's no way for code using GetBackgroundWorkerPid() to tell the
difference between a worker that has not started but will start
later and a worker that has not started and will never be started.
So, when this case happens, return BGWH_STOPPED instead.  Update the
comments to reflect this.

The preceding fix by itself is insufficient to fix the problem,
because the old code also didn't send a notification to the process
identified in bgw_notify_pid when startup failed.  That might've
been technically correct under the theory that the status of the
worker was BGWH_NOT_YET_STARTED, because the status would indeed not
change when the worker failed to start, but now that we're more
usefully reporting BGWH_STOPPED, a notification is needed.

Without these fixes, code which starts background workers and then
uses the recommended APIs to wait for those background workers to
start would hang indefinitely if the postmaster failed to fork a
worker.

Amit Kapila and Robert Haas

Discussion: http://postgr.es/m/CAA4eK1KDfKkvrjxsKJi3WPyceVi3dH1VCkbTJji2fuwKuB=3uw@mail.gmail.com
2017-12-06 08:58:27 -05:00
..
access Simplify do_pg_start_backup's API by opening pg_tblspc internally. 2017-12-04 18:37:54 -05:00
bootstrap Exclude flex-generated code from coverage testing 2017-10-16 16:28:11 -04:00
catalog Minor code beautification in partition_bounds_equal. 2017-12-01 13:52:59 -05:00
commands Fix EXPLAIN ANALYZE of hash join when the leader doesn't participate. 2017-12-05 10:55:56 -08:00
executor Fix Parallel Append crash. 2017-12-06 08:42:50 -05:00
foreign Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
lib Allow to avoid NUL-byte management for stringinfos and use in format.c. 2017-10-11 16:01:52 -07:00
libpq Check channel binding flag at end of SCRAM exchange 2017-12-01 09:53:26 -05:00
main Install Windows crash dump handler before all else. 2017-11-12 14:31:00 -08:00
nodes Support Parallel Append plan nodes. 2017-12-05 17:28:39 -05:00
optimizer Support Parallel Append plan nodes. 2017-12-05 17:28:39 -05:00
parser Re-allow INSERT .. ON CONFLICT DO NOTHING on partitioned tables. 2017-12-01 12:53:21 -05:00
po Translation updates 2017-08-07 13:55:34 -04:00
port Add some const decorations to prototypes 2017-11-10 13:38:57 -05:00
postmaster Report failure to start a background worker. 2017-12-06 08:58:27 -05:00
regex Mop-up for commit 85feb77aa0. 2017-09-22 11:35:12 -04:00
replication Simplify do_pg_start_backup's API by opening pg_tblspc internally. 2017-12-04 18:37:54 -05:00
rewrite Fix creation of resjunk tlist entries for inherited mixed UPDATE/DELETE. 2017-11-27 17:54:07 -05:00
snowball Add some const decorations to prototypes 2017-11-10 13:38:57 -05:00
statistics Support boolean columns in functional-dependency statistics. 2017-12-04 11:51:43 -05:00
storage Support Parallel Append plan nodes. 2017-12-05 17:28:39 -05:00
tcop SQL procedures 2017-11-30 11:03:20 -05:00
tsearch Update typedefs.list and re-run pgindent 2017-11-29 09:24:24 -05:00
utils Support Parallel Append plan nodes. 2017-12-05 17:28:39 -05:00
.gitignore
common.mk Add ICU_CFLAGS to global CPPFLAGS 2017-06-12 15:57:22 -04:00
Makefile Inject $(ICU_LIBS) regardless of platform. 2017-08-20 21:22:18 -07:00
nls.mk Translation updates 2017-05-15 12:19:54 -04:00