use LW_SHARED in dsa_get_total_size()

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Rahila Syed <rahilasyed90(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: use LW_SHARED in dsa_get_total_size()
Date: 2025-12-02 17:17:39
Message-ID: aS8fMzWs9e8iHxk2@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 02, 2025 at 10:31:33AM -0600, Nathan Bossart wrote:
> On Tue, Dec 02, 2025 at 02:28:29PM +0530, Rahila Syed wrote:
>> Thank you for highlighting the discussions. I'm unsure about the best
>> approach here, but I think it would be safe to stay consistent with the
>> rest of the code in dsa.c, especially since it's unclear that the use of
>> LW_EXCLUSIVE for reading values in dsa is a mistake.
>
> Okay. I switched to LW_EXCLUSIVE and will consider starting a new thread
> to use LW_SHARED when possible in dsa.c.

Here is a patch that switches to LW_SHARED in dsa_get_total_size() and
dsa_get_total_size_from_handle(). Another candidate was dsa_dump(), but
that function appears to do some things that require more than a shared
lock. In any case, it's just a debugging function, and I found no uses
in-tree or elsewhere.

--
nathan

Attachment Content-Type Size
v1-0001-use-LW_SHARED-in-dsa.c-when-appropriate.patch text/plain 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-12-02 17:49:05 Re: All-visible pages with valid prune xid are confusing
Previous Message Nathan Bossart 2025-12-02 16:31:33 Re: show size of DSAs and dshash tables in pg_dsm_registry_allocations