pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Sami Imseih <samimseih@gmail.com>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Improve LWLock tranche name visibility across backends
Date: Mon, 14 Jul 2025 14:46:50 -0500
Message-ID: <aHVeqtsltQyBBvAM@nathan> (raw)
In-Reply-To: <CAA5RZ0uic7Us255mFPJSrMFH7UY-RR8YZcjBzNDzfE4gFREDGQ@mail.gmail.com>
References: <CAA5RZ0vvED3naph8My8Szv6DL4AxOVK3eTPS0qXsaKi=bVdW2A@mail.gmail.com>
	<aG9/OKQRgPUCxmsX@ip-10-97-1-34.eu-west-3.compute.internal>
	<CAA5RZ0ui5+=Q3ouxbrjSKa1xJvOjDD2tNYfkG-UtJJNNc-4E=g@mail.gmail.com>
	<aHDYHKdEyZiV/Aob@ip-10-97-1-34.eu-west-3.compute.internal>
	<CAA5RZ0vK_EuHwGj8nWkb1UwYjDbqvj+ZyiYPYn3CRsU8uwKUsQ@mail.gmail.com>
	<aHGJBt37dg37f1bE@nathan>
	<CAA5RZ0uic7Us255mFPJSrMFH7UY-RR8YZcjBzNDzfE4gFREDGQ@mail.gmail.com>

On Mon, Jul 14, 2025 at 02:34:00PM -0500, Sami Imseih wrote:
>> Why do we need three different places for the lock names? Is there a
>> reason we can't put it all in shared memory?
> 
> The real reason I felt it was better to keep three separate locations is that
> it allows for a clear separation between user-defined tranches registered
> during postmaster startup and those registered during a normal backend. The
> tranches registered during postmaster are inherited by the backend via
> fork() (or EXEC_BACKEND), and therefore, the dshash table will only be used
> by a normal backend.
> 
> Since DSM is not available during postmaster, if we were to create a DSA
> segment in place, similar to what's done in StatsShmemInit(), we would also
> need to ensure that the initial shared memory is sized appropriately. This is
> because it would need to be large enough to accommodate all user-defined
> tranches registered during postmaster, without having to rely on new
> dsm segments.
> From my experimentation, this sizing is not as straightforward as simply
> calculating # of tranches * size of a tranche entry.
> 
> I still think we should create the dsa during postmaster, as we do with
> StatsShmemInit, but it would be better if postmaster keeps its hands off this
> dshash and only normal backends can use them.

Ah, I missed the problem with postmaster.  Could we have the first backend
that needs to access the table be responsible for creating it and
populating it with the built-in/requested-at-startup entries?  Also, is
there any chance that postmaster might need to access the tranche names?

-- 
nathan





view thread (107+ messages)  latest in thread

Message-ID: <aHVeqtsltQyBBvAM@nathan>
Permalink:  ../aHVeqtsltQyBBvAM@nathan/
Also on:    postgresql.org/message-id/aHVeqtsltQyBBvAM@nathan

 · 

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-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, samimseih@gmail.com, bertranddrouvot.pg@gmail.com
  Subject: Re: Improve LWLock tranche name visibility across backends
  In-Reply-To: <aHVeqtsltQyBBvAM@nathan>

* 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