pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feed[PATCH v2 1/1] fix LWLock shmem reinitialization
1+ messages / 1 participants
[nested] [flat]
* [PATCH v2 1/1] fix LWLock shmem reinitialization
@ 2025-09-17 03:11 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 1+ messages in thread
From: Nathan Bossart @ 2025-09-17 03:11 UTC (permalink / raw)
---
src/backend/storage/lmgr/lwlock.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
inline patch 1: src/backend/storage/lmgr/lwlock.c (+7/-1 lines) download inline-1.patch
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 46c82c63ca5..626f0fbdac1 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -192,6 +192,9 @@ typedef struct NamedLWLockTrancheRequest
int NamedLWLockTrancheRequests = 0;
NamedLWLockTrancheRequest *NamedLWLockTrancheRequestArray = NULL;
+/* postmaster's local copy of the request array */
+static NamedLWLockTrancheRequest *LocalNamedLWLockTrancheRequestArray;
+
/* shared memory counter of registered tranches */
int *LWLockCounter = NULL;
@@ -396,6 +399,9 @@ LWLockShmemSize(void)
Size size;
int numLocks = NUM_FIXED_LWLOCKS;
+ if (LocalNamedLWLockTrancheRequestArray)
+ NamedLWLockTrancheRequestArray = LocalNamedLWLockTrancheRequestArray;
+
/* Calculate total number of locks needed in the main array. */
numLocks += NumLWLocksForNamedTranches();
@@ -459,7 +465,7 @@ CreateLWLocks(void)
{
memcpy(ptr, NamedLWLockTrancheRequestArray,
NamedLWLockTrancheRequests * sizeof(NamedLWLockTrancheRequest));
- pfree(NamedLWLockTrancheRequestArray);
+ LocalNamedLWLockTrancheRequestArray = NamedLWLockTrancheRequestArray;
NamedLWLockTrancheRequestArray = (NamedLWLockTrancheRequest *) ptr;
ptr += NamedLWLockTrancheRequests * sizeof(NamedLWLockTrancheRequest);
}
--
2.39.5 (Apple Git-154)
--U22hRdN7XmUh2Va9--
^ permalink raw reply [nested|flat] 1+ messages in thread
only message in thread
Thread overview: 1+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-09-17 03:11 [PATCH v2 1/1] fix LWLock shmem reinitialization Nathan Bossart <nathan@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox