RE: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE

Поиск
Список
Период
Сортировка
От Aya Iwata (Fujitsu)
Тема RE: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE
Дата
Msg-id OS7PR01MB1196405302B700736580DEE49EAA8A@OS7PR01MB11964.jpnprd01.prod.outlook.com
обсуждение исходный текст
Ответ на Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE
Список pgsql-hackers
Hi Pavel-san

Thank you for your feedback!

> From: Pavel Stehule <pavel.stehule@gmail.com> 
> Sent: Thursday, December 18, 2025 12:33 AM
> To: Iwata, Aya/岩田 彩 <iwata.aya@fujitsu.com>
> Cc: Michael Paquier <michael@paquier.xyz>; Peter Smith <smithpb2250@gmail.com>; Chao Li <li.evan.chao@gmail.com>;
Kuroda,Hayato/黒田 隼人 <kuroda.hayato@fujitsu.com>; pgsql-hackers <pgsql-hackers@postgresql.org>
 
> Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE
>> Hi Pavel-san,
>> 
>> >> So maybe there should be ALTER DATABASE ... RENAME ... FORCE - or if FORCE can terminare all workers (without
specialFLAG) ?
 
>> > 
>> > For the proposed feature, we've added a flag allowing each extension developer to decide whether to terminate it
viaDROP/ALTER DATABASE.
 
>> > Adding a FORCE option to ALTER to let database definition modifiers decide whether to force termination of
backgroundworkers might be better discussed in a separate thread.
 
>> > 
>> > When I thought about it - there can be a second alternative.
>> > 
>> > Introduce a pair of flags BGWORKER_INTERRUPTABLE and BGWORKER_PROTECTED (the names can be enhanced or changed).
BGWORKER_INTERRUPTABLEcan be default. 
 
>> > ALTER DATABASE RENAME and related commands can stop any non protected workers. ALTER DATABASE RENAME FORCE can
stopany workers (including protected). 
 
>> 
>> I can't image any use cases for BGWORKER_PROTECTED. Do you have any idea?
>> Also, I think the parameter settings might get a complicated.
>> If we start discussing the "FORCE" option, it is better to think about this parameter.
>> 
>> > Is there any reason why BGWORKER_INTERRUPTABLE cannot be default? Probably nobody would block some possibly common
operationson database level without strong reason.
 
>> 
>> As Michael-san mentioned in a previous email, this behavior has remained unchanged since bgworkers were introduced
inv9.3. 
 
>> I don't see a compelling reason to alter it now. Additionally, this specification can be modified later.

> I understand the request for unchanging behaviour - but I am not sure if this concept is really helpful - or if the
namingis best. I am afraid so this feature without changing the workers code is useless (and maybe it is wanted).
 

It is our intention; this feature would enable when developer expressly set.

> Any worker should be interruptable by sigterm. And then the name BGWORKER_INTERRUPTABLE is little bit vague. Maybe
somelike BGWORKER_CAREFREE_INTERRUPTABLE can be better (or some like this - maybe BGWORKER_CANCELABLE)? This can be a
signalfrom bgworker's authors - it is ok to kill the worker anytime when it is necessary. 
 

That's right, "interruptable" may not be appropriate. This is because even bgworkers without this flag set can be
interruptedby sigterm.
 
Hmm, I feel these ideas may not be clear what it does. Do someone have other idea?

> Some workers can have the flag BGW_NEVER_RESTART - cannot be used as signal so this worker is protected, and others
canbe terminated safely, because they will be restarted after 60 seconds?
 

In my understanding, you are suggesting that the bgworker which set bgw_restart_time as BGW_NEVER_RESTART is not
terminatedby DROP/ALTER, right? 
 
Do you think what kind of use cases might there be?

Best Regards,
Aya Iwata

В списке pgsql-hackers по дате отправления: