Re: How to kill a Background worker and Its metadata

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Akash Agrawal <aagrawa6(at)ncsu(dot)edu>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: How to kill a Background worker and Its metadata
Date: 2016-06-29 03:52:33
Message-ID: CAMsr+YG-fD+mP-BNZDheVYucC7=oUn8ByTQSFz7RKkVX2MRS2Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28 June 2016 at 08:28, Akash Agrawal <aagrawa6(at)ncsu(dot)edu> wrote:

> I've handled SIGTERM signal. pg_terminate_backend send signals (SIGTERM)
> to backend processes identified by process ID. And also, after this call I
> am able to track in my logs that the background worker gets terminated.
>
> Yet, I am only able to register first 8 background workers. I am using
> select worker_spi1_launch(1) to launch it every time. This is why I guess
> there is some metadata maintained which has got to be deleted.
>

(Please reply below other posts, not above)

The bgworker API currently offers no way to enumerate bgworkers or
unregister them from the outside. The only way to unregister a dynamic
bgworker is to:

* proc_exit(0) from within the worker; or

* register it with BGW_NO_RESTART so it doesn't auto-restart in the
first place.

This is a deficiency in the bgworker API, but there are workarounds in
place and other things are more important for now. Just make your your
workers proc_exit(0) on SIGTERM or don't register them as auto-restarting.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-06-29 03:53:17 Re: primary_conninfo missing from pg_stat_wal_receiver
Previous Message Rushabh Lathia 2016-06-29 03:32:39 Re: ERROR: ORDER/GROUP BY expression not found in targetlist