Re: pg_usleep for multisecond delays

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_usleep for multisecond delays
Date: 2023-02-10 14:58:25
Message-ID: CA+TgmoYmzveX1L2YG2Syogz5rfGMrBfo04OKC=LSz5HGO1qUEw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 10, 2023 at 3:30 AM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-02-10 15:18:34 Re: pg_usleep for multisecond delays
Previous Message Masahiko Sawada 2023-02-10 14:52:41 Re: Support logical replication of DDLs