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-11T21:58:30Z
Lists: pgsql-hackers
On Fri, Jul 11, 2025 at 04:32:13PM -0500, Sami Imseih wrote: > Now, what I think will be a good API is to provide an alternative to > LWLockRegisterTranche, > which now takes in both a tranche ID and tranche_name. The new API I propose is > LWLockRegisterTrancheWaitEventCustom which takes only a tranche_name > and internally > calls WaitEventCustomNew to add a new wait_event_info to the hash > table. The wait_event_info > is made up of classId = PG_WAIT_LWLOCK and LWLockNewTrancheId(). > > I prefer we implement a new API for this to make it explicit that this > API will both register > a tranche and create a custom wait event. I do not think we should get > rid of LWLockRegisterTranche > because it is used by CreateLWLocks during startup and I don't see a > reason to change that. > See the attached v1. Hm. I was thinking we could have LWLockNewTrancheId() take care of registering the name. The CreateLWLocks() case strikes me as a special path. IMHO LWLockRegisterTranche() should go away. > Is there a concern with a custom wait event to be created implicitly > via the GetNamed* APIs? I'm not sure I see any particular advantage to using custom wait events versus a dedicated LWLock tranche name table. If anything, the limits on the number of tranches and the lengths of the names gives me pause. -- 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