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: Rahila Syed <rahilasyed90@gmail.com>, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-08-12T19:48:50Z
Lists: pgsql-hackers
I haven't followed the latest discussion, but I took a look at the patch. + It is possible to use a <literal>tranche_id</literal> that was not retrieved + using <function>LWLockNewTrancheId</function>, but this is not recommended. + The ID may clash with an already registered tranche name, or the specified + name may not be found. In such cases, looking up the name will return a generic + "extension" tranche name. Is there any reason to continue allowing this? For example, maybe we could ERROR if LWLockInitialize()/GetLWTrancheName() are given a tranche_id greater than the number allocated. I guess I'm not following why we should gracefully handle these kinds of coding errors, especially when they result in unhelpful behavior like an "extension" tranche. +#else +elog(ERROR, "injection points not supported"); +#endif This causes compilation to fail when injection points are not enabled. I haven't combed through the patch character-by-character, but upon a read-through, the general shape looks reasonable to me. As a general note, I'd suggest adding more commentary throughout and finding opportunities to simplify and/or clean up the code as much as possible. -- 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