Re: Avoid multiple SetLatch() calls in procsignal_sigusr1_handler()

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Avoid multiple SetLatch() calls in procsignal_sigusr1_handler()
Date: 2026-03-30 01:30:00
Message-ID: CALj2ACV6a64cqQksb-0nga886dZyu-G8zhPwpqn23JEV=uUgCw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Sun, Mar 29, 2026 at 5:30 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> While reviewing the patch in [1], I noticed this issue and ended up here.
> I agree with the approach and have attached a revised version of the patch.

Thank you for reviving this patch.

> I understand the concern. There's no guarantee that PostgreSQL functions
> behave identically across major versions, so removing redundant SetLatch()
> calls is generally fine. However, as you are concerned, extensions might call
> these functions and implicitly rely on the extra SetLatch(). Since the patch
> doesn't change the API, such behavioral changes may be hard for extension
> authors to notice. Also they will be not in release notes. In practice,
> they would probably catch this during testing against a new major version,
> though.

I'm still +1 for removing these redundant SetLatch calls from the
multiplexed SIGUSR1 handlers. It not only keeps the signal handlers
consistent but also avoids an additional function call and memory
barrier from within the signal handler (a micro optimization).

I reviewed the v2 patch and it looks good to me.

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-03-30 01:35:00 Re: Introduce XID age based replication slot invalidation
Previous Message Alexander Korotkov 2026-03-30 01:20:41 Re: Asynchronous MergeAppend