Re: background worker and normal exit

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: background worker and normal exit
Date: 2013-05-26 02:38:55
Message-ID: CAB7nPqTLJvDXoATZNCujQw+Mf=naid3n_oWgncTnBBpZivbbLg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, May 26, 2013 at 6:16 AM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:

> I found that the normal exit (i.e., with exit code 0) of bgworker
> always leads to
> the immediate restart of bgworker whatever bgw_restart_time is. Is
> this intentional?
>
Yes, per the docs:
http://www.postgresql.org/docs/devel/static/bgworker.html
"Background workers are expected to be continuously running; if they exit
cleanly, postgres will restart them immediately."

> Not only crash but also normal exit should go along with bgw_restart_time?
>
bgw_restart_time corresponds to the time a bgworker is restarted in case of
a crash only.

> I'm now writing the bgworker which is allowed to be running only
> during recovery.
> After recovery ends, that bgworker is expected to exit with code 0. I
> was thinking
> to avoid the restart of the bgworker after normal exit, by using
> BGW_NEVER_RESTART.
>
This flag makes a worker not to restart only in case of a crash. To solve
your problem, you could as well allow your process to restart and put it in
indefinite sleep if server is not in recovery such it it will do nothing in
your case.

Regards,
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gurjeet Singh 2013-05-26 05:04:33 Re: Processing long AND/OR lists
Previous Message William King 2013-05-26 01:27:18 Re: View Index and UNION