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-27T04:49:11Z
Lists: pgsql-hackers

Attachments

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

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

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

Like the attached.

--
Sami

Commits

  1. Fix outdated comment on MainLWLockArray

  2. Fix RequestNamedLWLockTranche in single-user mode

  3. Minor comment fixes to yesterday's LWLock tranche refactoring

  4. Move ShmemIndexLock into ShmemAllocator

  5. Use ShmemInitStruct to allocate lwlock.c's shared memory

  6. Use a separate spinlock to protect LWLockTranches

  7. Refactor how user-defined LWLock tranches are stored in shmem

  8. Rename MAX_NAMED_TRANCHES to MAX_USER_DEFINED_TRANCHES

  9. Fix re-initialization of LWLock-related shared memory.