Re: Improve LWLock tranche name visibility across backends
Sami Imseih <samimseih@gmail.com>
From: Sami Imseih <samimseih@gmail.com>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Rahila Syed <rahilasyed90@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-08-28T15:28:54Z
Lists: pgsql-hackers
Attachments
- v15-0001-Improve-LWLock-tranche-registration.patch (application/octet-stream) patch v15-0001
- v15-0003-Remove-the-DSA-suffix-for-tranches-created-with-.patch (application/octet-stream) patch v15-0003
- v15-0002-Tests-for-LWLock-tranche-registration-improvemen.patch (application/octet-stream) patch v15-0002
> The check has to be done before the strlen() call, if not it segfault: I don't know what I was thinking there :( silly mistake. It was also missed in RequestNamedLWLockTranche. > Most of the places where NAMEDATALEN is mentioned in sgml files also mention > it's 64 bytes. Should we do the same here? I don't have an issue with that, although I did not like how the various docs are not consistent. Some claim 64 characters, others claim 63 bytes. They are not the same since multibyte characters are allowed. For example [0] is definitely wrong, and it should say "bytes". I think it would be nice if all references to NAMEDATALEN point to a single doc (a follow-up topic, perhaps) > "Any unused entries in the array will contain NULL": this is not true anymore. > It now contains empty strings: Yes. Fixed the comment. Also, it has not yet been discussed that the max number of named tranches should be. Thus far I have been using a likely extremely high value of 1024. In v15, I set it to 128 as that was a possibly more realistic number and one suggested earlier [1]. There maybe some odd cases out there in which this value may not be enough; many extensions that init lwlocks or maybe some extension out there that uses partitioned locks and assign a unique tranche for every lock. I have not seen anything like this. Maybe it's not be something to worry about and we can say 128 is reasonable sufficiently large. I would hate to reserve too much shared memory for this unnecessarily. Thoughts? [0] https://www.postgresql.org/docs/18/runtime-config-logging.html#GUC-APPLICATION-NAME [1] https://www.postgresql.org/message-id/5to6tftuml6nkas4jaaljfzecasvslxq3mumeslh74wsol4mzw%40rgxpxxlqqwtf -- Sami
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