Re: Improve LWLock tranche name visibility across backends
Nathan Bossart <nathandbossart@gmail.com>
From: Nathan Bossart <nathandbossart@gmail.com>
To: Sami Imseih <samimseih@gmail.com>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-07-31T21:24:38Z
Lists: pgsql-hackers
Attachments
I've attached a rebased version of the patch. On Mon, Jul 21, 2025 at 11:26:44PM -0500, Sami Imseih wrote: > Unlike the local list of tranche names, appending to and searching the > shared memory list requires an LWLock; in exclusive mode to append, and > shared mode to search. The thing that stood out the most to me is how much more expensive looking up the lock name is. At the risk of suggesting even more complexity, I'm wondering if we should add some sort of per-backend cache to avoid the need for locking and dsa_get_address() calls every time you need to look up a lock name. Also, I suspect that there might be some concerns about the API changes. While it should be a very easy fix, that seems likely to break a lot of extensions. I don't know if it's possible to make this stuff backward compatible, and I also don't know if we really want to, as that'll both introduce more complexity and keep folks using the old API. (That being said, I just looked on GitHub and Debian Code Search and was surprised at how few uses of LWLockNewTrancheId() and LWLockRegisterTranche() there are...) -- nathan
Commits
-
test_dsa: Avoid leaking LWLock tranches.
- c5c74282f2ea 19 (unreleased) landed
-
Teach DSM registry to ERROR if attaching to an uninitialized entry.
- b26d76f64327 18.2 landed
- ac2800ddc185 17.8 landed
- 1165a933aab1 19 (unreleased) landed
-
Add a test harness for the LWLock tranche code.
- 16607718c010 19 (unreleased) landed
-
Revert recent change to RequestNamedLWLockTranche().
- d814d7fc3d52 19 (unreleased) landed
-
Move dynamically-allocated LWLock tranche names to shared memory.
- 38b602b0289f 19 (unreleased) landed
-
Prepare DSM registry for upcoming changes to LWLock tranche names.
- 5487058b56e0 19 (unreleased) landed
-
Add GetNamedDSA() and GetNamedDSHash().
- fe07100e82b0 19 (unreleased) cited