pgsql: Fix status reporting for terminated bgworkers that were never st

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix status reporting for terminated bgworkers that were never st
Date: 2015-03-19 15:11:50
Message-ID: E1YYc6w-00008g-0D@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix status reporting for terminated bgworkers that were never started.

Previously, GetBackgroundWorkerPid() would return BGWH_NOT_YET_STARTED
if the slot used for the worker registration had not been reused by
unrelated activity, and BGWH_STOPPED if it had. Either way, a process
that had requested notification when the state of one of its
background workers changed did not receive such notifications. Fix
things so that GetBackgroundWorkerPid() always returns BGWH_STOPPED in
this situation, so that we do not erroneously give waiters the
impression that the worker will eventually be started; and send
notifications just as we would if the process terminated after having
been started, so that it's possible to wait for the postmaster to
process a worker termination request without polling.

Discovered by Amit Kapila during testing of parallel sequential scan.
Analysis and fix by me. Back-patch to 9.4; there may not be anyone
relying on this interface yet, but if anyone is, the new behavior is a
clear improvement.

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/76d07a2a0633836a82c43beb8ed3b08a64dc3d46

Modified Files
--------------
src/backend/postmaster/bgworker.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2015-03-19 17:02:15 pgsql: doc: ALTER DOMAIN VALIDATE CONSTRAINT can also fail
Previous Message Robert Haas 2015-03-19 15:11:49 pgsql: Fix status reporting for terminated bgworkers that were never st