Re: pg_usleep for multisecond delays - Mailing list pgsql-hackers

From Robert Haas
Subject Re: pg_usleep for multisecond delays
Date
Msg-id CA+TgmoYmzveX1L2YG2Syogz5rfGMrBfo04OKC=LSz5HGO1qUEw@mail.gmail.com
Whole thread Raw
In response to Re: pg_usleep for multisecond delays  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: pg_usleep for multisecond delays
List pgsql-hackers
On Fri, Feb 10, 2023 at 3:30 AM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> Maybe for these cases where a WaitLatch is not desired, it'd be simpler
> to do pg_usleep (5L * 1000 * 1000);

I somehow feel that we should be trying to get rid of cases where
WaitLatch is not desired.

That's probably overly simplistic - there might be cases where the
caller isn't just polling and has a really legitimate need to wait for
5 seconds of wall clock time. But even in that case, it seems like we
want to respond to barriers and interrupts during that time, in almost
all cases.

I wonder if we should have a wrapper around WaitLatch() that documents
that if the latch is set before the time expires, it will reset the
latch and try again to wait for the remaining time, after checking for
interrupts etc.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Support logical replication of DDLs
Next
From: Tom Lane
Date:
Subject: Re: pg_usleep for multisecond delays