public inbox for [email protected]
help / color / mirror / Atom feedFrom: Peter Eisentraut <[email protected]>
To: ISHAN CHHANGANI . <[email protected]>
To: pgsql-hackers <[email protected]>
Subject: Re: Switch background worker on/off in runtime.
Date: Sun, 2 Jun 2024 23:22:07 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <SL2P216MB13807782E32729AAD3DC805CF5FC2@SL2P216MB1380.KORP216.PROD.OUTLOOK.COM>
References: <SL2P216MB13807782E32729AAD3DC805CF5FC2@SL2P216MB1380.KORP216.PROD.OUTLOOK.COM>
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.
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Switch background worker on/off in runtime.
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox