Re: A new function to wait for the backend exit after termination

Поиск
Список
Период
Сортировка
От Bharath Rupireddy
Тема Re: A new function to wait for the backend exit after termination
Дата
Msg-id CALj2ACV8J22Rq29U+hkayBz8LGyva6e-+8EkJvkscSKoBXkMQA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: A new function to wait for the backend exit after termination  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: A new function to wait for the backend exit after termination  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-hackers
Thanks for the feedback.

On Wed, Oct 21, 2020 at 8:01 PM David G. Johnston
<david.g.johnston@gmail.com> wrote:
>
> On Wed, Oct 21, 2020 at 6:13 AM Magnus Hagander <magnus@hagander.net> wrote:
>>
>> I think it would be nicer to have a pg_terminate_backend(pid, wait=false), so a function with a second parameter
whichdefaults to the current behaviour of not waiting. And it might be a good idea to also give it a timeout
parameter?
>
> Agreed on the overload, and the timeouts make sense too - with the caller deciding whether a timeout results in a
failureor a false return value.
 
>

If the backend is terminated within the user specified timeout then
the function returns true, otherwise false.

>
>>> 2. pg_wait_backend() -- which waits for a given backend process. Note that this function has to be used carefully
afterpg_terminate_backend(), if used on a backend that's not ternmited it simply keeps waiting in a loop.
 
>>
>> It seems this one also very much would need a timeout value.
>
> Is there a requirement for waiting to be superuser only?  You are not affecting any session but your own during the
waitingperiod.
 
>

IIUC, in the same patch instead of returning an error in case of
non-superusers, do we need to wait for user provided timeout
milliseconds until the current user becomes superuser and then throw
error if still non-superuser, and proceed further if superuser?

Do we need to have a new function that waits until a current
non-superuser in a session becomes superuser?

Something else?

>
> I could imagine, in theory at least, wanting to wait for a backend to go idle as well as for it disappearing.  Scope
creepin terms of this patch's goal but worth at least considering now.
 
>

IIUC, do we need a new option, something like pg_wait_backend(pid,
timeout, waituntil) where "waituntil" if specified "idle" waits until
the given backend goes to idle mode, or "termination" waits until
termination?

If my understanding is wrong, could you please explain more?



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: A new function to wait for the backend exit after termination
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: [HACKERS] logical decoding of two-phase transactions