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-27T14:53:36Z
Lists: pgsql-hackers

Attachments

> Committed with that little change, thanks!

Thanks!

I think there is one more comment cleanup in lwlock.c

 /*
- * This points to the main array of LWLocks in shared memory.  Backends inherit
- * the pointer by fork from the postmaster (except in the EXEC_BACKEND case,
- * where we have special measures to pass it down).
+ * This points to the main array of LWLocks in shared memory.
  */

we no longer need to take special measures to pass down MainLWLockArray
through the BackendParameters.

--
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.