Re: Clean up NamedLWLockTranche stuff

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Clean up NamedLWLockTranche stuff
Date: 2026-03-27 03:57:44
Message-ID: CAA5RZ0s+-_d6RBSfmLvekGLTCi2EZ7hiHp3RhMVDEexGXq=7Vg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> > Thanks!
> >
> > On 26/03/2026 18:34, Sami Imseih wrote:
> >>> I propose the attached refactorings to make this less confusing. See
> >>> commit messages for details.
> >>
> >> I only took a look at 0001 so far, and I do agree with this statement
> >> in the commit message:
>
> I committed these now, but I'm all ears if you still have comments on
> the rest of the patches.

Sorry for the delay. I see you committed the rest. The only issue I found
is with d6eba30

+/* backend-local copy of NamedLWLockTranches->num_user_defined */
+static int LocalNumUserDefinedTranches;

The comment here should reference "LWLockTranches->num_user_defined "
instead.

>> rename RequestNamedLWLockTranche() to RequestUserDefinedLWLockTranche()
>> and LWLockNewTrancheId() to RegisterUserDefinedLWLockTranche()

> I'd rather not change RequestNamedLWLockTranche(), because I think
> LWLockNewTrancheId() is better and should be used in new code.

That's fair.

>> v19 is already changing the signature of LWLockNewTrancheId(), so maybe
>> improving the names of these APIs makes sense to do.

> Oh, I didn't realize we changed the LWLockNewTrancheId() signature!
> Yeah, if we're changing it anyway, we might as well rename it. I'm not
> sure if I like RegisterUserDefinedLWLockTranche() better, but let's
> think it through.

Maybe, RegisterNewLWLockTrancheId() could be more meaningful?

Also, there are a few places in lwlock.c where "named tranches" is mentioned.
Maybe we should just say "user-defined tranches" instead?

--
Sami Imseih
Amazon Web Services (AWS)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-03-27 03:58:41 Re: Use SIGTERM instead of SIGUSR1 for slotsync worker to exit during promotion?
Previous Message Bharath Rupireddy 2026-03-27 03:54:22 Re: POC: Parallel processing of indexes in autovacuum