From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: parallel mode and parallel contexts |
Date: | 2015-03-06 12:44:19 |
Message-ID: | CA+TgmoZpBFoXNmHRt13ktKJR1RXmABbKusd6rz9Z=EqBDLUrVA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Mar 6, 2015 at 7:01 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> Today, while testing parallel_seqscan patch, I encountered one
> intermittent issue (it hangs in below function) and I have question
> related to below function.
>
> +void
> +WaitForParallelWorkersToFinish(ParallelContext *pcxt)
> +{
> ..
> + for (;;)
> + {
> ..
> + CHECK_FOR_INTERRUPTS();
> + for (i = 0; i < pcxt->nworkers; ++i)
> + {
> + if (pcxt->worker[i].error_mqh != NULL)
> + {
> + anyone_alive = true;
> + break;
> + }
> + }
> +
> + if (!anyone_alive)
> + break;
> +
> + WaitLatch(&MyProc->procLatch, WL_LATCH_SET, -1);
> + ResetLatch(&MyProc->procLatch);
> + }
>
> Isn't there a race condition in this function such that after it finds
> that there is some alive worker and before it does WaitLatch(), the
> worker completes its work and exits, now in such a case who is
> going to wake the backend waiting on procLatch?
It doesn't matter whether some other backend sets the process latch
before we reach WaitLatch() or after we begin waiting. Either way,
it's fine.
It would be bad if the process could exit without setting the latch at
all, though. I hope that's not the case.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2015-03-06 13:02:06 | Re: MD5 authentication needs help |
Previous Message | Amit Kapila | 2015-03-06 12:01:54 | Re: parallel mode and parallel contexts |