pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Nathan Bossart <nathan@postgresql.org>
Subject: [PATCH v2 1/1] fix LWLock shmem reinitialization
Date: Tue, 16 Sep 2025 22:11:47 -0500
---
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--
Message-ID: <no-message-id-19398@localhost>
Permalink: ../no-message-id-19398@localhost/
Also on: postgresql.org/message-id/no-message-id-19398@localhost
copy link · copy postgr.es · copy git am
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: nathan@postgresql.org
Subject: Re: [PATCH v2 1/1] fix LWLock shmem reinitialization
In-Reply-To: <no-message-id-19398@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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