On Wed, Sep 30, 2026 at 5:13 PM Heikki Linnakangas <[email protected]> wrote:
>
> On 25/09/2026 10:07, Ashutosh Bapat wrote:
> > Replacing the IsUnderPostmaster check with a check for whether shared
> > memory has been initialized seems appropriate. However, ShmemIndex
> > remains non-NULL when the postmaster restarts after a backend crash
> > and recreates shared memory. The registered callbacks are retained,
> > but the pending requests are rebuilt by calling those callbacks again.
> > If the callbacks return the same sizes as before, we will not
> > encounter an unknown size. Still, the check seems brittle: it would
> > not reject an unknown size supplied by a callback during restart, and
> > the request would instead fail later in the size calculation.
>
> A-ha, good catch.
>
> > We need to reject SHMEM_ATTACH_UNKNOWN_SIZE before allocating the
> > shared-memory segment because its size must be known. Could we perform
> > this check in ShmemGetRequestedSize()? That seems like a more specific
> > place for it than ShmemRequestInternal(), which handles requests both
> > at startup and afterward.
>
> Hmm, I guess that'd work too. It feels a little weird to not get the
> error immediately in the ShmemRequestStruct() call though.

With ShmemIndex == NULL fix, the check is at a place from where it
matters and two places are connected via a callback which is not
apparent. I have a feeling that we might see some more reports in this
area. But let's wait for that.

>
> Ok, I picked a mix of these test changes that I liked the best, and
> committed :-). Thank you both!

Thanks.

-- 
Best Wishes,
Ashutosh Bapat


Reply via email to