Re: Wait for parallel workers to attach

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Geoghegan <pg(at)bowt(dot)ie>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Subject: Re: Wait for parallel workers to attach
Date: 2018-01-31 03:16:24
Message-ID: CA+TgmobHMN53MN8FeZpV1hRz+wSbbjW4neyxPQabaW_nJ0J3nA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 30, 2018 at 10:10 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>> known_started_workers looks a lot like any_message_received. Perhaps
>> any_message_received should be renamed to known_started_workers and
>> reused here.
>
> Sure, that sounds good to me. Do you prefer a separate patch for
> renaming any_message_received to known_started_workers or is it okay
> to have it along with the main patch?

A single patch sounds OK.

>> After all, if we know that a worker was started, there's
>> no need for WaitForParallelWorkersToFinish to again call
>> GetBackgroundWorkerPid() for it.
>
> I think in above sentence you wanted to say
> WaitForParallelWorkersToAttach, not WaitForParallelWorkersToFinish.
> Am I right?

Yes.

>> I think that you shouldn't need the 10ms delay loop; waiting forever
>> should work. If a work fails to start, the postmaster should send
>> SIGUSR1 which should set our latch.
>>
> I am not getting what exactly you are suggesting here. The wait loop
> is intended for the case when some workers are not started. We want
> to wait for sometime before checking again whether workers are
> started. I wanted to avoid busy looping waiting for some worker to
> start. I think in most cases we don't need to wait, but for some
> corner cases where postmaster didn't get chance to start a worker, we
> should avoid busy looping waiting for a worker to start.

I agree we need to avoid busy-looping. What I'm saying is that we
don't need a timeout. Why do you think we need a timeout? We have
bgw_notify_pid so that we will get a signal instead of having to poll.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-01-31 03:18:16 Re: [HACKERS] [PATCH]make pg_rewind to not copy useless WAL files
Previous Message Amit Kapila 2018-01-31 03:10:06 Re: Wait for parallel workers to attach