Re: Dynamic background workers & docs question

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Dynamic background workers & docs question
Date: 2014-03-24 11:20:37
Message-ID: CAB7nPqRFxVutfdxe6UcmjYN4VUvZBdWLvH4TbHnmsaqdmWVraQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 24, 2014 at 5:54 PM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> I was looking at http://www.postgresql.org/docs/devel/static/bgworker.html
> with a client today.
>
> It says:
> "Unlike RegisterBackgroundWorker, which can only be called from within the
> postmaster,RegisterDynamicBackgroundWorker must be called from a regular
> backend."
>
> Is that the correct restriction? In particular, don't we allow calling
> RegisterDynamicBackgroundWorker from another background worker? (In the
> launcher/worker kind of scenario, like AutoVacuum).
Yes, you can start a dynamic background worker from another background
worker, have a look for example at contrib/worker_spi. Perhaps the
correct wording would be "RegisterDynamicBackgroundWorker must be
called from a regular backend or another background worker".

> Also:
> "Background workers are expected to be continuously running; if they exit
> cleanly, postgres will restart them immediately. "
>
> This doesn't apply to dynamic ones, which we might want to clarify. Do we
> have a "term" for non-dynamic background workers? "static workers"?
In the code or the documentation, there is no explicit
differentiation, bgworkers are either called plainly "bgworker", or
"dynamic bgworker". Perhaps the solution here is simply to say
"background workers started by the postmaster are expected blabla".
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2014-03-24 11:22:52 Re: Review: plpgsql.extra_warnings, plpgsql.extra_errors
Previous Message Petr Jelinek 2014-03-24 10:58:40 Re: Review: plpgsql.extra_warnings, plpgsql.extra_errors