pgsql: Notify bgworker registrant after freeing worker slot.

Started by Robert Haasover 9 years ago4 messagescomitters
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t203566
psql -h localhost -U postgres

Built from patchset v2 (message #2), July 29, 2026 at 01:06 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t203566_2 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t203566_2 && git checkout t203566_2

Patchset v2 (message #2) is on t203566_2

Jump to latest
#1Robert Haas
robertmhaas@gmail.com

Notify bgworker registrant after freeing worker slot.

Tom Lane observed buildfarm failures caused by the select_parallel
regression test trying to launch new parallel queries before the
worker slots used by the previous ones were freed. Try to fix this by
having the postmaster free the worker slots before it sends the
SIGUSR1 notifications to the registering process. This doesn't
completely eliminate the possibility that the user backend might
(correctly) observe the worker as dead before the slot is free, but I
believe it should make the window significantly narrower.

Patch by me, per complaint from Tom Lane. Reviewed by Amit Kapila.

Discussion: /messages/by-id/30673.1487310734@sss.pgh.pa.us

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/aea5d298362e881b13d95a48c5ae116879237389

Modified Files
--------------
src/backend/postmaster/bgworker.c | 33 +++++++++++++++++++++++++++++
src/backend/postmaster/postmaster.c | 6 +++---
src/include/postmaster/bgworker_internals.h | 1 +
3 files changed, 37 insertions(+), 3 deletions(-)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#2Amit Kapila
amit.kapila16@gmail.com
In reply to: Robert Haas (#1)
Re: pgsql: Notify bgworker registrant after freeing worker slot.

On Fri, Mar 3, 2017 at 9:27 AM, Robert Haas <rhaas@postgresql.org> wrote:

Notify bgworker registrant after freeing worker slot.

After this commit, I am seeing parallel queires being stucked on my
windows machine. I think the notify pid is stale in
ReportBackgroundWorkerExit() as we are freeing the same in
ForgetBackgroundWorker(). Attached patch fixes the problem for me.

Ashutosh Sharma has independently reported (offlist) this problem to me.

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

Attachments:

t203566_2
select_parallel_hang_v1.patchapplication/octet-stream; name=select_parallel_hang_v1.patchDownload+4-2
#3Robert Haas
robertmhaas@gmail.com
In reply to: Amit Kapila (#2)
Re: pgsql: Notify bgworker registrant after freeing worker slot.

On Mon, Mar 6, 2017 at 8:21 AM, Amit Kapila <amit.kapila16@gmail.com> wrote:

On Fri, Mar 3, 2017 at 9:27 AM, Robert Haas <rhaas@postgresql.org> wrote:

Notify bgworker registrant after freeing worker slot.

After this commit, I am seeing parallel queires being stucked on my
windows machine. I think the notify pid is stale in
ReportBackgroundWorkerExit() as we are freeing the same in
ForgetBackgroundWorker(). Attached patch fixes the problem for me.

Ashutosh Sharma has independently reported (offlist) this problem to me.

Thanks for the report and patch. Committed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#3)
Re: pgsql: Notify bgworker registrant after freeing worker slot.

Robert Haas <robertmhaas@gmail.com> writes:

On Mon, Mar 6, 2017 at 8:21 AM, Amit Kapila <amit.kapila16@gmail.com> wrote:

On Fri, Mar 3, 2017 at 9:27 AM, Robert Haas <rhaas@postgresql.org> wrote:

Notify bgworker registrant after freeing worker slot.

After this commit, I am seeing parallel queires being stucked on my
windows machine. I think the notify pid is stale in
ReportBackgroundWorkerExit() as we are freeing the same in
ForgetBackgroundWorker(). Attached patch fixes the problem for me.
Ashutosh Sharma has independently reported (offlist) this problem to me.

Thanks for the report and patch. Committed.

Hmm, maybe this also explains skink's recent failure in the
select_parallel test. I was going to go try to duplicate that, but
now maybe I'll just wait to see if its next run is green.

regards, tom lane

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers