public inbox for [email protected]
help / color / mirror / Atom feedFrom: Nathan Bossart <[email protected]>
Subject: [PATCH 1/1] fix RequestNamedLWLockTranche
Date: Fri, 27 Mar 2026 17:00:49 -0500
---
src/backend/storage/lmgr/lwlock.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 7a68071302a..f5b2a6d479d 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -630,6 +630,7 @@ void
RequestNamedLWLockTranche(const char *tranche_name, int num_lwlocks)
{
NamedLWLockTrancheRequest *request;
+ MemoryContext oldcontext;
if (!process_shmem_requests_in_progress)
elog(FATAL, "cannot request additional LWLocks outside shmem_request_hook");
@@ -652,10 +653,17 @@ RequestNamedLWLockTranche(const char *tranche_name, int num_lwlocks)
errdetail("No more than %d tranches may be registered.",
MAX_USER_DEFINED_TRANCHES)));
- request = MemoryContextAllocZero(PostmasterContext, sizeof(NamedLWLockTrancheRequest));
+ if (IsPostmasterEnvironment)
+ oldcontext = MemoryContextSwitchTo(PostmasterContext);
+ else
+ oldcontext = MemoryContextSwitchTo(TopMemoryContext);
+
+ request = palloc0(sizeof(NamedLWLockTrancheRequest));
strlcpy(request->tranche_name, tranche_name, NAMEDATALEN);
request->num_lwlocks = num_lwlocks;
NamedLWLockTrancheRequests = lappend(NamedLWLockTrancheRequests, request);
+
+ MemoryContextSwitchTo(oldcontext);
}
/*
--
2.50.1 (Apple Git-155)
--Lz5NZmdVPmVGc+6p--
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: [email protected]
Cc: [email protected]
Subject: Re: [PATCH 1/1] fix RequestNamedLWLockTranche
In-Reply-To: <no-message-id-724891@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox