pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Notify bgworker registrant after freeing worker slot.
4+ messages / 4 participants
[nested] [flat]

* pgsql: Notify bgworker registrant after freeing worker slot.
@ 2017-03-03 03:57 Robert Haas <rhaas@postgresql.org>
  2017-03-06 13:21 ` Re: pgsql: Notify bgworker registrant after freeing worker slot. Amit Kapila <amit.kapila16@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Robert Haas @ 2017-03-03 03:57 UTC (permalink / raw)
  To: pgsql-committers

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: http://postgr.es/m/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


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Notify bgworker registrant after freeing worker slot.
  2017-03-03 03:57 pgsql: Notify bgworker registrant after freeing worker slot. Robert Haas <rhaas@postgresql.org>
@ 2017-03-06 13:21 ` Amit Kapila <amit.kapila16@gmail.com>
  2017-03-06 17:23   ` Re: pgsql: Notify bgworker registrant after freeing worker slot. Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Amit Kapila @ 2017-03-06 13:21 UTC (permalink / raw)
  To: Robert Haas <rhaas@postgresql.org>; +Cc: pgsql-committers

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

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

Attachments:

select_parallel_hang_v1.patch (application/octet-stream, 988B) download diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index 42760b9..10e0f88 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -440,12 +440,14 @@ ReportBackgroundWorkerExit(slist_mutable_iter *cur) { RegisteredBgWorker *rw; BackgroundWorkerSlot *slot; + int notify_pid; rw = slist_container(RegisteredBgWorker, rw_lnode, cur->cur); Assert(rw->rw_shmem_slot < max_worker_processes); slot = &BackgroundWorkerData->slot[rw->rw_shmem_slot]; slot->pid = rw->rw_pid; + notify_pid = rw->rw_worker.bgw_notify_pid; /* * If this worker is slated for deregistration, do that before notifying @@ -458,8 +460,8 @@ ReportBackgroundWorkerExit(slist_mutable_iter *cur) rw->rw_worker.bgw_restart_time == BGW_NEVER_RESTART) ForgetBackgroundWorker(cur); - if (rw->rw_worker.bgw_notify_pid != 0) - kill(rw->rw_worker.bgw_notify_pid, SIGUSR1); + if (notify_pid != 0) + kill(notify_pid, SIGUSR1); } /*
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: pgsql: Notify bgworker registrant after freeing worker slot.
  2017-03-03 03:57 pgsql: Notify bgworker registrant after freeing worker slot. Robert Haas <rhaas@postgresql.org>
  2017-03-06 13:21 ` Re: pgsql: Notify bgworker registrant after freeing worker slot. Amit Kapila <amit.kapila16@gmail.com>
@ 2017-03-06 17:23   ` Robert Haas <robertmhaas@gmail.com>
  2017-03-06 18:44     ` Re: pgsql: Notify bgworker registrant after freeing worker slot. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Robert Haas @ 2017-03-06 17:23 UTC (permalink / raw)
  To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: pgsql-committers

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Notify bgworker registrant after freeing worker slot.
  2017-03-03 03:57 pgsql: Notify bgworker registrant after freeing worker slot. Robert Haas <rhaas@postgresql.org>
  2017-03-06 13:21 ` Re: pgsql: Notify bgworker registrant after freeing worker slot. Amit Kapila <amit.kapila16@gmail.com>
  2017-03-06 17:23   ` Re: pgsql: Notify bgworker registrant after freeing worker slot. Robert Haas <robertmhaas@gmail.com>
@ 2017-03-06 18:44     ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2017-03-06 18:44 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; pgsql-committers

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2017-03-06 18:44 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 03:57 pgsql: Notify bgworker registrant after freeing worker slot. Robert Haas <rhaas@postgresql.org>
2017-03-06 13:21 ` Amit Kapila <amit.kapila16@gmail.com>
2017-03-06 17:23   ` Robert Haas <robertmhaas@gmail.com>
2017-03-06 18:44     ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox