Re: Inconsistent bgworker behaviour

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Beena Emerson <memissemerson(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Inconsistent bgworker behaviour
Date: 2015-01-07 13:05:59
Message-ID: 54AD2F37.2050002@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2015-01-07 13:08:09 Re: NODE
Previous Message Craig Ringer 2015-01-07 12:55:38 Re: BDR Error restarted