Re: Improve LWLock tranche name visibility across backends

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Sami Imseih <samimseih@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Rahila Syed <rahilasyed90@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-09-02T14:45:52Z
Lists: pgsql-hackers
On Mon, Sep 01, 2025 at 10:18:46AM +0000, Bertrand Drouvot wrote:
> Changes look good.

Thanks for looking.

> Not directly related, but I think that we can get rid of:
> 
> size = add_size(size, LWLOCK_PADDED_SIZE);
> 
> in LWLockShmemSize() and of:
> 
> ptr += LWLOCK_PADDED_SIZE - ((uintptr_t) ptr) % LWLOCK_PADDED_SIZE;
> 
> in CreateLWLocks(), and just make use of CACHELINEALIGN().

Let's take care of the tranche name stuff first.

-- 
nathan



Commits

  1. test_dsa: Avoid leaking LWLock tranches.

  2. Teach DSM registry to ERROR if attaching to an uninitialized entry.

  3. Add a test harness for the LWLock tranche code.

  4. Revert recent change to RequestNamedLWLockTranche().

  5. Move dynamically-allocated LWLock tranche names to shared memory.

  6. Prepare DSM registry for upcoming changes to LWLock tranche names.

  7. Add GetNamedDSA() and GetNamedDSHash().