From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Kouhei Kaigai <kaigai(at)ak(dot)jp(dot)nec(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Fabrízio Mello <fabriziomello(at)gmail(dot)com>, Thom Brown <thom(at)linux(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Parallel Seq Scan |
Date: | 2015-03-18 06:22:13 |
Message-ID: | CAA4eK1J2D+J=oo+jtNU9UKN89k384CUCRtb=kfY1yXHBDuwNrA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Mar 17, 2015 at 7:54 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
> On Tue, Mar 17, 2015 at 1:42 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
wrote:
> > The problem occurs in second loop inside DestroyParallelContext()
> > where it calls WaitForBackgroundWorkerShutdown(). Basically
> > WaitForBackgroundWorkerShutdown() just checks for BGWH_STOPPED
> > status, refer below code in parallel-mode patch:
> >
> > + status = GetBackgroundWorkerPid(handle, &pid);
> > + if (status == BGWH_STOPPED)
> > + return status;
> >
> > So if the status here returned is BGWH_NOT_YET_STARTED, then it
> > will go for WaitLatch and will there forever.
> >
> > I think fix is to check if status is BGWH_STOPPED or
BGWH_NOT_YET_STARTED,
> > then just return the status.
> >
> > What do you say?
>
> No, that's not right. If we return when the status is
> BGWH_NOT_YET_STARTED, then the postmaster could subsequently start the
> worker.
>
> Can you try this:
>
> diff --git a/src/backend/postmaster/bgworker.c
> b/src/backend/postmaster/bgworker.c
> index f80141a..39b919f 100644
> --- a/src/backend/postmaster/bgworker.c
> +++ b/src/backend/postmaster/bgworker.c
> @@ -244,6 +244,8 @@ BackgroundWorkerStateChange(void)
> rw->rw_terminate = true;
> if (rw->rw_pid != 0)
> kill(rw->rw_pid, SIGTERM);
> + else
> + ReportBackgroundWorkerPID(rw);
> }
> continue;
> }
>
It didn't fix the problem. IIUC, you have done this to ensure that
if worker is not already started, then update it's pid, so that we
can get the required status in WaitForBackgroundWorkerShutdown().
As this is a timing issue, it can so happen that before Postmaster
gets a chance to report the pid, backend has already started waiting
on WaitLatch().
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2015-03-18 06:23:12 | Re: Question about TEMP tables |
Previous Message | Jeevan Chalke | 2015-03-18 06:11:58 | Re: Add LINE: hint when schemaname.typename is a non-existent schema |