Re: putting a bgworker to rest

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: putting a bgworker to rest
Date: 2013-04-23 17:22:13
Message-ID: 20130423172213.GH8499@alap2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2013-04-23 14:11:26 -0300, Alvaro Herrera wrote:
> Andres Freund wrote:
> > On 2013-04-23 11:59:43 -0300, Alvaro Herrera wrote:
> > > Andres Freund wrote:
> > > > Hi all,
> > > >
> > > > I noticed the need to simply stop a bgworker after its work is done but
> > > > still have it restart in unusual circumstances like a crash.
> > > > Obviously I can just have it enter a loop where it checks its latch and
> > > > such, but that seems a bit pointless.
> > > >
> > > > Would it make sense to add an extra return value or such for that?
> > >
> > > KaiGai also requested some more flexibility in the stop timing and
> > > shutdown sequence. I understand the current design that workers are
> > > always on can be a bit annoying.
> > >
> > > How would postmaster know when to restart a worker that stopped?
> >
> > I had imagined we would assign some return codes special
> > meaning. Currently 0 basically means "restart immediately", 1 means
> > "crashed, wait for some time", everything else results in a postmaster
> > restart. It seems we can just assign returncode 2 as "done", probably
> > with some enum or such hiding the numbers.
>
> So a "done" worker would never be restarted, until postmaster sees a
> crash or is itself restarted? I guess that'd be useful for workers
> running during recovery, which terminate when recovery completes. Is
> that your use case?

Well, its not actual postgres recovery, but something similar in the
context of logical replication.

Greetings,

Andres Freund

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Gudeman 2013-04-23 18:08:04 Re: minimizing the target list for foreign data wrappers
Previous Message Paul Hinze 2013-04-23 17:14:16 Simultaneous index creates on different schemas cause deadlock?