Re: Improve LWLock tranche name visibility across backends
| От | Nathan Bossart | 
|---|---|
| Тема | Re: Improve LWLock tranche name visibility across backends | 
| Дата | |
| Msg-id | aLmZWcqRiPY7QRi-@nathan обсуждение исходный текст | 
| Ответ на | Re: Improve LWLock tranche name visibility across backends (Rahila Syed <rahilasyed90@gmail.com>) | 
| Список | pgsql-hackers | 
On Thu, Sep 04, 2025 at 03:29:52PM +0530, Rahila Syed wrote: > Since updates to LocalLWLockCounter and LWLockTrancheNames are performed > while holding the lock, but reading LocalLWLockCounter and then > LWLockTrancheNames in GetLWTrancheName can occur without acquiring the > same lock in case trancheID < LocalLWLockCounter, There is a small window > between updating LocalLWLockCounter and adding the name to > LWLockTrancheNames. During this window, if GetLWTrancheNames is called, > it might attempt to access a name in LWLockTrancheNames that hasn't been > added yet. We hold the lock when reading/writing the shared-memory LWLockCounter. There's no need to take a lock when reading the backend-local LocalLWLockCounter, as it can't be modified by any other process. Additionally, when adding a new tranche name, we hold the lock the entire time while we bump the shared-memory counter and copy the name, so there's no chance another backend will see the counter update but not the name or attempt to use the same LWLockTrancheNames slot. -- nathan
В списке pgsql-hackers по дате отправления: