Re: Restart pg_usleep when interrupted

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Restart pg_usleep when interrupted
Date: 2024-06-28 22:50:20
Message-ID: AC328D21-21D6-4FFC-8F6B-BFE9AD940524@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Thanks for the feedback!

> On Jun 28, 2024, at 4:34 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Sami Imseih <samimseih(at)gmail(dot)com> writes:
>> Reattaching the patch.
>
> I feel like this is fundamentally a wrong solution, for the reasons
> cited in the comment for pg_usleep: long sleeps are a bad idea
> because of the resulting uncertainty about whether we'll respond to
> interrupts and such promptly. An example here is that if we get
> a query cancel interrupt, we should probably not insist on finishing
> out the current sleep before responding.

The case which brought up this discussion is the pg_usleep that
is called within the vacuum_delay_point being interrupted.

When I read the same code comment you cited, it sounded to me
that “long sleeps” are those that are in seconds or minutes. The longest
vacuum delay allowed is 100ms.

> Therefore, rather than "improving" pg_usleep (and uglifying its API),
> the right answer is to fix parallel vacuum leaders to not depend on
> pg_usleep in the first place. A better idea might be to use
> pg_sleep() or equivalent code.

Yes, that is a good idea to explore and it will not require introducing
an awkward new API. I will look into using something similar to
pg_sleep.

Regards,

Sami

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2024-06-28 23:12:56 Re: cfbot update: Using GitHub for patch review
Previous Message Thomas Munro 2024-06-28 22:11:39 Re: Restart pg_usleep when interrupted