Re: Error handling in after-startup shmem requests

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Error handling in after-startup shmem requests
Date: 2026-08-26 12:23:22
Message-ID: 3808326d-a574-4dbb-9132-ac3206e5f77e@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 26/08/2026 08:59, Ayush Tiwari wrote:
> This approach looks good to me overall.  I built the v2 series with
> assertions and injection points enabled, and all five tests passed.
>
> I had one question about the lifetime of the options copy.  It is still
> allocated in TopMemoryContext, while the after-startup path no longer calls
> pfree(request->options).  The PG_FINALLY block clears
> pending_shmem_requests, but could that leave the options allocated until
> backend exit?  The impact seems small, but perhaps the options should be
> freed before clearing the list, or allocated in the same context as the
> requests?

You're right. I changed it to use TopMemoryContext like you had it
originally. That seems more clear, after all.

> One minor test nit:
>
> - The comment says "A failure in the requesting shared memory", but the
>   injection point triggers in test_shmem_init(), so would "initializing
>   shared memory" be more accurate?

Yeah. I did some other cleanups in the test too, and merged the tests
into the commits with the code fixes. Here's a new version, if you want
to have one final look.

- Heikki

Attachment Content-Type Size
v3-0001-Fix-backend-state-after-a-failed-after-startup-sh.patch text/x-patch 8.9 KB
v3-0002-Track-which-shmem-areas-have-been-fully-initializ.patch text/x-patch 12.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2026-08-26 12:24:35 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Jonathan Gonzalez V. 2026-08-26 12:18:31 Re: locale / encoding / meson cleanup