Re: Improve LWLock tranche name visibility across backends

Sami Imseih <samimseih@gmail.com>

From: Sami Imseih <samimseih@gmail.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-08-04T20:23:31Z
Lists: pgsql-hackers
> On Mon, Aug 04, 2025 at 11:32:19AM -0500, Sami Imseih wrote:
> > With a local hash table, I don't think it's necessary to introduce new
> > code for managing
> > a DSA based list of tranche names as is done in v3. We can go back to
> > storing the shared
> > trance names in dshash.
> >
> > What do you think?
>
> My first thought is that a per-backend hash table seems too
> expensive/complicated for this.  Couldn't it just be an array like we have
> now?

We can, but I was considering simplicity of implementation, and using a
local hash table is slightly simpler.

That said, since we're dealing with an append-only data structure, a hash
table is probably more than we need. All we need is index-based lookup,
so I’ll go with the local array to mirror the shared ( dsa ) array.

--
Sami



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