Re: Parallel Seq Scan - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Parallel Seq Scan
Date
Msg-id CA+TgmoY93pf0rfc2F2ZAf=ubXLJyQb1jbn3pXw+4kOnwJnONNQ@mail.gmail.com
Whole thread Raw
In response to Re: Parallel Seq Scan  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: Parallel Seq Scan
List pgsql-hackers
On Tue, Mar 17, 2015 at 1:42 AM, Amit Kapila <amit.kapila16@gmail.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;              }
 

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



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Precedence of standard comparison operators
Next
From: hitesh ramani
Date:
Subject: GSoC 2015: Introduction and Doubt regarding a Project.