Switch background worker on/off in runtime.
Hi,
Is it possible to switch on/off a background worker in runtime?
worker.bgw_flags = BGWORKER_SHMEM_ACCESS;
worker.bgw_start_time = BgWorkerStart_PostmasterStart;
I want to switch off the worker based on some flag value, etc, either from the main process or the worker itself.
Are there any already existing examples?
Thanks,
Ishan.
--
The information contained in this electronic communication is intended
solely for the individual(s) or entity to which it is addressed. It may
contain proprietary, confidential and/or legally privileged information.
Any review, retransmission, dissemination, printing, copying or other use
of, or taking any action in reliance on the contents of this information by
person(s) or entities other than the intended recipient is strictly
prohibited and may be unlawful. If you have received this communication in
error, please notify us by responding to this email or telephone and
immediately and permanently delete all copies of this message and any
attachments from your system(s). The contents of this message do not
necessarily represent the views or policies of BITS Pilani.
Hi ISHAN
On Fri, May 31, 2024 at 2:28 PM ISHAN CHHANGANI . <
f20200230@hyderabad.bits-pilani.ac.in> wrote:
Hi,
Is it possible to switch on/off a background worker in runtime?
As per my understanding there is no such way to do it on runtime. But you
can kill it by using the following command
select pg_terminate_backend(pid of bgworker);
Regards
Kashif Zeeshan
Bitnine Global
Show quoted text
worker.bgw_flags = BGWORKER_SHMEM_ACCESS;
worker.bgw_start_time = BgWorkerStart_PostmasterStart;
I want to switch off the worker based on some flag value, etc, either from
the main process or the worker itself.Are there any already existing examples?
Thanks,
Ishan.
The information contained in this electronic communication is intended
solely for the individual(s) or entity to which it is addressed. It may
contain proprietary, confidential and/or legally privileged information.
Any review, retransmission, dissemination, printing, copying or other use
of, or taking any action in reliance on the contents of this information by
person(s) or entities other than the intended recipient is strictly
prohibited and may be unlawful. If you have received this communication in
error, please notify us by responding to this email or telephone and
immediately and permanently delete all copies of this message and any
attachments from your system(s). The contents of this message do not
necessarily represent the views or policies of BITS Pilani.
On 31.05.24 11:28, ISHAN CHHANGANI . wrote:
Is it possible to switch on/off a background worker in runtime?
worker.bgw_flags =BGWORKER_SHMEM_ACCESS;
worker.bgw_start_time =BgWorkerStart_PostmasterStart;
I want to switch off the worker based on some flag value, etc, either
from the main process or the worker itself.Are there any already existing examples?
I think this depends more on your exact use case. For example, the
logical replication background workers have sophisticated logic to do
this. There is a launcher, which is itself a background worker, which
launches other per-subscription workers. And there are commands to
disable subscriptions, which would among other things stop their
corresponding background workers. That logic is specific to the needs
of the logic replication system. You might get some ideas from that.
But in general it will need a bit of custom logic.