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: Alexander Lakhin <exclusion@gmail.com>, Rahila Syed <rahilasyed90@gmail.com>, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-11-10T18:05:14Z
Lists: pgsql-hackers
Attachments
On Mon, Nov 10, 2025 at 10:49:58AM -0600, Nathan Bossart wrote: > On Mon, Nov 10, 2025 at 10:26:17AM -0600, Nathan Bossart wrote: >> It's probably a good idea to avoid tranche leaks, but IMHO there's room for >> improvement in the DSM registry, too. IIUC the problem is that the DSM >> segment is still being added to the registry and found by other backends >> despite the initialization callback failing. My first instinct is that we >> should keep track of whether the DSM segments/DSAs/dshash tables in the >> registry have been fully initialized and to just ERROR in other backends >> when attaching if they aren't. That shouldn't really happen in practice, >> but it'd be good to avoid the strange errors, anyway. 0001 does this. When applied, Alexander's reproduction steps fail with ERROR: requested DSM segment failed initialization This one should probably get back-patched to v17, where the DSM registry was introduced. > BTW if we really wanted to avoid leaking tranches in test_dsa, we'd need to > store the ID in shared memory. Your patch helps in the case where a single > backend is repeatedly calling test_dsa_resowners(), but other backends > would still allocate their own tranche. I don't see a strong need to fix > this on back-branches, given these functions run exactly once as part of a > test, but fixing it on master seems worthwhile so that extension authors > don't copy/paste this broken code. 0002 does this. -- 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