Re: Can a child process detect postmaster death when in pg_usleep?

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Can a child process detect postmaster death when in pg_usleep?
Date: 2021-04-20 02:06:39
Message-ID: CALj2ACV6omyMurs0y2KWpEr7S-wE7ziR-NimFwB9Or+tF2R1rA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 15, 2021 at 11:48 AM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> > We definitely have replaced a lot of sleeps with latch.c primitives
> > over the past few years, since we got WL_EXIT_ON_PM_DEATH and
> > condition variables. There may be many more to improve... You
> > mentioned autovacuum... yeah, Stephen fixed one of these with commit
> > 4753ef37, but yeah it's not great to have those others in there...
>
> I have not looked at the commit 4753ef37 previously, but it
> essentially addresses the problem with pg_usleep for vacuum delay. I'm
> thinking we can also replace pg_usleep in below places based on the
> fact that pg_usleep should be avoided in 1) short waits in a loop 2)
> when wait time is dependent on user configurable parameters. And using
> WaitLatch may require us to add wait event types to WaitEventTimeout
> enum, but that's okay.

I'm attaching 3 patches that replace pg_usleep with WaitLatch: 0001 in
lazy_truncate_heap, 0002 in do_pg_stop_backup and 0003 for Pre and
Post Auth Delay. Regression tests pass with these patches. Please
review them.

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

Attachment Content-Type Size
v1-0001-Use-a-WaitLatch-for-lock-waiting-in-lazy_truncate.patch application/x-patch 2.8 KB
v1-0002-Use-a-WaitLatch-in-do_pg_stop_backup.patch application/x-patch 1.9 KB
v1-0003-Use-a-WaitLatch-for-Pre-and-Post-Auth-Delay.patch application/x-patch 6.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2021-04-20 02:15:23 Re: pg_amcheck option to install extension
Previous Message Bharath Rupireddy 2021-04-20 02:04:43 Re: Performance degradation of REFRESH MATERIALIZED VIEW