Re: Improve LWLock tranche name visibility across backends
Sami Imseih <samimseih@gmail.com>
From: Sami Imseih <samimseih@gmail.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>,
Rahila Syed <rahilasyed90@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-08-26T19:56:22Z
Lists: pgsql-hackers
Attachments
- v12-0002-Tests-for-LWLock-tranche-registration-improvemen.patch (application/octet-stream) patch v12-0002
- v12-0001-Improve-LWLock-tranche-registration.patch (application/octet-stream) patch v12-0001
> > On Mon, Aug 25, 2025 at 04:59:41PM -0500, Sami Imseih wrote: > > > hmm, can we really avoid a shared lock when reading from shared memory? > > > considering access for both reads and writes can be concurrent to shared > > > memory. We are also taking an exclusive lock when writing a new tranche. > > > > We probably want to hold a lock while we 1) increment LWLockCounter and > > copy a new tranche name to memory and > > In the last rev, I removed the spinlock acquired on ShmemLock in-lieu of > a LWLock. This is because I wanted a single LWLock acquisition while > both incrementing LWLockCounter and writing to shared memory, and > doing this much work, particularly writing to shared memory, > with a spinlock seemed inappropriate. With that said, this is not high > concurrency of performance sensitive activity at all, so perhaps I was > being overly paranoid. Here is v12 that replaces the LWLock to access the shared memory with a ShmemLock and implements a local counter. -- 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