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

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, "Hou, Zhijie" <houzj(dot)fnst(at)cn(dot)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Muhammad Usama <m(dot)usama(at)gmail(dot)com>
Subject: Re: A new function to wait for the backend exit after termination
Date: 2021-03-16 09:38:04
Message-ID: CALj2ACV3j=DoWJJNj_wEOQ=gU6o47HiT_PXtH6SBQiWeK8Qzdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 15, 2021 at 10:38 AM Fujii Masao
<masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:
> On 2021/03/15 12:27, Bharath Rupireddy wrote:
> > On Sun, Mar 7, 2021 at 2:39 PM Bharath Rupireddy
> > <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> >> Attaching v7 patch for further review.
> >
> > Attaching v8 patch after rebasing on to the latest master.
>
> Thanks for rebasing the patch!

Thanks for reviewing.

> - WAIT_EVENT_XACT_GROUP_UPDATE
> + WAIT_EVENT_XACT_GROUP_UPDATE,
> + WAIT_EVENT_BACKEND_TERMINATION
>
> These should be listed in alphabetical order.

Done.

> In pg_wait_until_termination's do-while loop, ResetLatch() should be called. Otherwise, it would enter busy-loop after any signal arrives. Because the latch is kept set and WaitLatch() always exits immediately in that case.

Done.

> + /*
> + * Wait in steps of waittime milliseconds until this function exits or
> + * timeout.
> + */
> + int64 waittime = 10;
>
> 10 ms per cycle seems too frequent?

Increased it to 100msec.

> + ereport(WARNING,
> + (errmsg("timeout cannot be negative or zero: %lld",
> + (long long int) timeout)));
> +
> + result = false;
>
> IMO the parameter should be verified before doing the actual thing.

Done.

> Why is WARNING thrown in this case? Isn't it better to throw ERROR like pg_promote() does?

Done.

Attaching v9 patch for further review.

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
v9-0001-pg_terminate_backend-with-wait-and-timeout.patch application/x-patch 12.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message houzj.fnst@fujitsu.com 2021-03-16 09:40:53 RE: Avoid CommandCounterIncrement in RI trigger when INSERT INTO referencing table
Previous Message Fujii Masao 2021-03-16 09:27:53 Re: comment fix in postmaster.c