Re: parallel mode and parallel contexts

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: parallel mode and parallel contexts
Дата
Msg-id CA+TgmoZDuaAi0UMNTPb5TV8yQQVVa58+89nUtqM8jJ6G6FyWEw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: parallel mode and parallel contexts  (Amit Kapila <amit.kapila16@gmail.com>)
Список pgsql-hackers
On Thu, Jan 15, 2015 at 9:09 AM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> On Thu, Jan 15, 2015 at 6:52 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> On Thu, Jan 15, 2015 at 7:00 AM, Amit Kapila <amit.kapila16@gmail.com>
>> wrote:
>> > +HandleParallelMessages(void)
>> > +{
>> > ..
>> > ..
>> > + for (i = 0; i < pcxt->nworkers; ++i)
>> > + {
>> > + /*
>> > + * Read messages for as long as we have an error queue; if we
>> > + * have hit (or hit while reading) ReadyForQuery, this will go to
>> > + * NULL.
>> > + */
>> > + while (pcxt->worker[i].error_mqh != NULL)
>> > + {
>> > + shm_mq_result res;
>> > +
>> > + CHECK_FOR_INTERRUPTS();
>> > +
>> > + res = shm_mq_receive(pcxt->worker[i].error_mqh, &nbytes,
>> > + &data, true);
>> > + if (res == SHM_MQ_SUCCESS)
>> >
>> > Here we are checking the error queue for all the workers and this loop
>> > will continue untill all have sent ReadyForQuery() message ('Z') which
>> > will make this loop continue till all workers have finished their work.
>> > Assume situation where first worker has completed the work and sent
>> > 'Z' message and second worker is still sending some tuples, now above
>> > code will keep on waiting for 'Z' message from second worker and won't
>> > allow to receive tuples sent by second worker till it send 'Z' message.
>> >
>> > As each worker send its own 'Z' message after completion, so ideally
>> > the above code should receive the message only for worker which has
>> > sent the message.  I think for that it needs worker information who has
>> > sent the message.
>>
>> Are you talking about HandleParallelMessages() or
>> WaitForParallelWorkersToFinish()?  The former doesn't wait for
>> anything; it just handles any messages that are available now.
>
> I am talking about HandleParallelMessages().  It doesn't wait but
> it is looping which will make it run for longer time as explained
> above.  Just imagine a case where there are two workers and first
> worker has sent 'Z' message and second worker is doing some
> work, now in such a scenario loop will not finish until second worker
> also send 'Z' message or error.  Am I missing something?

Blah.  You're right.  I intended to write this loop so that it only
runs until shm_mq_receive() returns SHM_MQ_WOULD_BLOCK.  But that's
not what I did.  Will fix.

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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Safe memory allocation functions
Следующее
От: Tom Lane
Дата:
Сообщение: Re: s_lock.h default definitions are rather confused