Re: How to kill a Background worker and Its metadata - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: How to kill a Background worker and Its metadata
Date
Msg-id CAMsr+YG-fD+mP-BNZDheVYucC7=oUn8ByTQSFz7RKkVX2MRS2Q@mail.gmail.com
Whole thread Raw
In response to Re: How to kill a Background worker and Its metadata  (Akash Agrawal <aagrawa6@ncsu.edu>)
List pgsql-hackers


On 28 June 2016 at 08:28, Akash Agrawal <aagrawa6@ncsu.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

pgsql-hackers by date:

Previous
From: Rushabh Lathia
Date:
Subject: Re: ERROR: ORDER/GROUP BY expression not found in targetlist
Next
From: Michael Paquier
Date:
Subject: Re: primary_conninfo missing from pg_stat_wal_receiver