On Wed, Mar 10, 2021 at 1:11 AM Thomas Munro <thomas.mu...@gmail.com> wrote: > In passing I noticed that lwlock.c contains 3 comments about bogus > wakeups due to sharing proc->sem with the heavyweight lock manager and > ProcWaitForSignal. Commit 6753333f55e (9.5) switched those things > from proc->sem to proc->procLatch. ProcArrayGroupClearXid() and > TransactionGroupUpdateXidStatus() also use proc->sem though, and I > haven't studied how those might overlap with with LWLockWait(), so I'm > not sure what change to suggest.
Here's a patch to remove the misleading comments.
From 195d601893eede68b051ac84174b6f810f1bb761 Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.mu...@gmail.com> Date: Thu, 3 Jun 2021 13:48:16 +1200 Subject: [PATCH] Remove more obsolete comments about semaphores. Commit 6753333f stopped using semaphores as the sleep/wake mechanism for heavyweight locks, but some obsolete references to that scheme remained in comments. As with similar commit 25b93a29, back-patch all the way. Discussion: https://postgr.es/m/CA%2BhUKGLafjB1uzXcy%3D%3D2L3cy7rjHkqOVn7qRYGBjk%3D%3DtMJE7Yg%40mail.gmail.com --- src/backend/storage/lmgr/lwlock.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 55b9d7970e..1cd95f73b3 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -1302,14 +1302,8 @@ LWLockAcquire(LWLock *lock, LWLockMode mode) /* * Wait until awakened. * - * Since we share the process wait semaphore with the regular lock - * manager and ProcWaitForSignal, and we may need to acquire an LWLock - * while one of those is pending, it is possible that we get awakened - * for a reason other than being signaled by LWLockRelease. If so, - * loop back and wait again. Once we've gotten the LWLock, - * re-increment the sema by the number of additional signals received, - * so that the lock manager or signal manager will see the received - * signal when it next waits. + * Once we've gotten the LWLock, re-increment the sema by the number of + * additional signals received. */ LOG_LWDEBUG("LWLockAcquire", lock, "waiting"); @@ -1474,8 +1468,7 @@ LWLockAcquireOrWait(LWLock *lock, LWLockMode mode) { /* * Wait until awakened. Like in LWLockAcquire, be prepared for - * bogus wakeups, because we share the semaphore with - * ProcWaitForSignal. + * bogus wakeups. */ LOG_LWDEBUG("LWLockAcquireOrWait", lock, "waiting"); @@ -1688,14 +1681,8 @@ LWLockWaitForVar(LWLock *lock, uint64 *valptr, uint64 oldval, uint64 *newval) /* * Wait until awakened. * - * Since we share the process wait semaphore with the regular lock - * manager and ProcWaitForSignal, and we may need to acquire an LWLock - * while one of those is pending, it is possible that we get awakened - * for a reason other than being signaled by LWLockRelease. If so, - * loop back and wait again. Once we've gotten the LWLock, - * re-increment the sema by the number of additional signals received, - * so that the lock manager or signal manager will see the received - * signal when it next waits. + * It is possible that we get awakened for a reason other than being + * signaled by LWLockRelease. If so, loop back and wait again. */ LOG_LWDEBUG("LWLockWaitForVar", lock, "waiting"); -- 2.30.2