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

From: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(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: 2023-03-09 12:24:32
Message-ID: b5eab65a-e11b-6435-b6aa-dac206e17d38@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2/28/23 4:30 PM, Bharath Rupireddy wrote:
> Hi,
>
> Most of the multiplexed SIGUSR1 handlers are setting latch explicitly
> when the procsignal_sigusr1_handler() can do that for them at the end.

Right.

> These multiplexed handlers are currently being used as SIGUSR1
> handlers, not as independent handlers, so no problem if SetLatch() is
> removed from them.

Agree, they are only used in procsignal_sigusr1_handler().

> A few others do it right by saying /* latch will be
> set by procsignal_sigusr1_handler */.

Yeap, so do HandleProcSignalBarrierInterrupt() and HandleLogMemoryContextInterrupt().

> Although, calling SetLatch() in
> quick succession does no harm (it just returns if the latch was
> previously set), it seems unnecessary.
>

Agree.

> I'm attaching a patch that avoids multiple SetLatch() calls.
>
> Thoughts?
>

I agree with the idea behind the patch. The thing
that worry me a bit is that the changed functions are defined
as external and so may produce an impact outside of core pg and I'm
not sure that's worth it.

Otherwise the patch LGTM.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2023-03-09 12:51:31 Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?)
Previous Message Önder Kalacı 2023-03-09 12:18:28 Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher