Re: Clean up NamedLWLockTranche stuff
Sami Imseih <samimseih@gmail.com>
From: Sami Imseih <samimseih@gmail.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Nathan Bossart <nathandbossart@gmail.com>,
Robert Haas <robertmhaas@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2026-03-27T03:57:44Z
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)
Commits
-
Fix outdated comment on MainLWLockArray
- bd365b1ae510 19 (unreleased) landed
-
Fix RequestNamedLWLockTranche in single-user mode
- 2407c8db159d 19 (unreleased) landed
-
Minor comment fixes to yesterday's LWLock tranche refactoring
- 98993150c0a4 19 (unreleased) landed
-
Move ShmemIndexLock into ShmemAllocator
- 06d859aaf4e9 19 (unreleased) landed
-
Use ShmemInitStruct to allocate lwlock.c's shared memory
- 30d432502bf4 19 (unreleased) landed
-
Use a separate spinlock to protect LWLockTranches
- 12e3e0f2c8f7 19 (unreleased) landed
-
Refactor how user-defined LWLock tranches are stored in shmem
- d6eba30a245c 19 (unreleased) landed
-
Rename MAX_NAMED_TRANCHES to MAX_USER_DEFINED_TRANCHES
- cc88481aeb98 19 (unreleased) landed
-
Fix re-initialization of LWLock-related shared memory.
- c3cc2ab87d72 19 (unreleased) cited