Re: Calling PGReserveSemaphores() from CreateOrAttachShmemStructs

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Subject: Re: Calling PGReserveSemaphores() from CreateOrAttachShmemStructs
Date: 2025-08-26 07:11:44
Message-ID: CAExHW5uD95UnKdk4Y2rq-yELK6VMXN1bGfrr9o58=BBower3yg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Thomas,

On Mon, Aug 25, 2025 at 3:11 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>
> On Mon, Aug 25, 2025 at 9:10 PM Ashutosh Bapat
> <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
> > Is this change correct? Was there any reason to leave it like that in
> > e25626677f8076eb3ce94586136c5464ee154381? Or was it just something
> > that didn't fit in that commit?
>
> We/I just missed that opportunity when ripping that stuff out. It
> sounds like we might need a comment-only patch to back-patch to 18
> that would say something like "this is done here for historical
> reasons" so as not to confuse people with obsolete nonsense, and a
> follow up patch for master to do things in a more straightforward way
> as you said.

Thanks for the confirmation.

Attached patchset has two patches
0001 - backpatchable, adds the comment.
0002 - actual code changes for master. The changes are described in
the commit message in detail. I think ProcGlobalSemas() too, can be
converted into a macro or can be declared static inline, but I haven't
done so. I think it eliminates all the asymmetric handling of
semaphores.

>
> > If the change looks safe and useful, I will create CF entry for it so
> > that the patch gets tested on all platforms, and thus with different
> > definitions of PGReserveSemaphores().
>
> +1, will review, thanks!

Added a CF entry so that CI tests the changes on many platforms.
https://commitfest.postgresql.org/patch/5997/

--
Best Wishes,
Ashutosh Bapat

Attachment Content-Type Size
0001-PGReserveSemaphores-called-from-CreateShare-20250826.patch text/x-patch 2.0 KB
0002-Refactor-shared-memory-allocation-for-semap-20250826.patch text/x-patch 7.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alyona Vinter 2025-08-26 07:12:20 Re: Making WAL archiving faster — multi-file support and async ideas
Previous Message Amit Kapila 2025-08-26 06:44:56 Re: Conflict detection for update_deleted in logical replication