Re: Inconsistent bgworker behaviour - Mailing list pgsql-general

From Craig Ringer
Subject Re: Inconsistent bgworker behaviour
Date
Msg-id 54AD2F37.2050002@2ndquadrant.com
Whole thread Raw
In response to Inconsistent bgworker behaviour  (Beena Emerson <memissemerson@gmail.com>)
Responses Re: Inconsistent bgworker behaviour
List pgsql-general
On 01/07/2015 11:54 AM, Beena Emerson wrote:
>
>             ResetLatch(&MyProc->procLatch);
>             TerminateBackgroundWorker(workers[i]->handle);
>             WaitLatch(&MyProc->procLatch, WL_LATCH_SET, 0);

This doesn't guarantee that the worker of interest has terminated, just
that your latch got set.

You should make sure the worker of interest is actually dead, and you
didn't get a SIGUSR1 for some other reason.

We could probably use a WaitForBackgroundWorkerTermination(...) to
correspond to WaitForBackgroundWorkerStartup(...) .

I think you'll probably want to GetBackgroundWorkerPid(...) and examine
the returned BgwHandleStatus to see if it's BGWH_STOPPED . If not, keep
waiting. You might want a timeout to re-check.

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: BDR Error restarted
Next
From: Craig Ringer
Date:
Subject: Re: NODE