Re: [PATCH] Fix premature timeout in pg_promote() caused by signal interruptions

From: Robert Pang <robertpang(at)google(dot)com>
To: getiancheng_2012 <18663776784(at)163(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Fix premature timeout in pg_promote() caused by signal interruptions
Date: 2026-03-26 04:05:34
Message-ID: CAJhEC05t1JHWEWtmji2u5n8g_+WmROuF5YuN7UEbOA=cL16zXQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Michael and Tiancheng

On Tue, Mar 24, 2026 at 8:06 PM getiancheng_2012 <18663776784(at)163(dot)com>
wrote:

> ---- Replied Message ----
> From Michael Paquier<michael(at)paquier(dot)xyz> <michael(at)paquier(dot)xyz>
> Date 3/25/2026 10:28
> To Robert Pang<robertpang(at)google(dot)com> <robertpang(at)google(dot)com>
> Cc pgsql-hackers<pgsql-hackers(at)postgresql(dot)org>
> <pgsql-hackers(at)postgresql(dot)org>
> Subject Re: [PATCH] Fix premature timeout in pg_promote() caused by
> signal interruptions
>
> On Wed, Mar 11, 2026 at 09:44:07AM -0700, Robert Pang wrote:
>
> The current implementation of pg_promote() calculates a fixed number
> of loop iterations based on the timeout value, assuming each loop
> waits exactly 100 ms for the backend latch. However, if the backend
> receives an unrelated signal (e.g., from
> client_connection_check_interval), it wakes up early. These repeated,
> unrelated wakeups cause the loop counter to deplete much faster than
> intended, leading to a premature timeout.
>
>
> It is true that we can do better here, and your proposal about having
> a more precise timeout calculation looks like a sensible improvement
> for this case.
>
> No objections regarding your patch. I would like to apply it on HEAD,
> if there are no objections.
> --
> Michael
>
>
> Hi all,
>
> Overall LGTM. Just a small comment:
>
> "+ end_time = GetCurrentTimestamp() + wait_seconds * 1000000L;"
>
> I think we can use TimestampTzPlusSeconds(GetCurrentTimestamp(), wait_seconds).
>
>
> Best regards
>
> Tiancheng Ge
>
>
Thank you for reviewing this patch. The use of TimestampTzPlusSeconds()
will be good.

Best regards
Robert Pang

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2026-03-26 04:05:40 Re: Adding locks statistics
Previous Message Sami Imseih 2026-03-26 03:31:28 Re: Refactor query normalization into core query jumbling