Re: Detach shared memory in Postmaster child if not needed

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, Rui Zhao <xiyuan(dot)zr(at)alibaba-inc(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, tgl <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Detach shared memory in Postmaster child if not needed
Date: 2024-07-29 19:41:44
Message-ID: b4b5c4bf-10f6-4a32-93f3-280c4e7ed79b@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 29/07/2024 21:10, Robert Haas wrote:
> On Mon, Jul 29, 2024 at 5:57 AM Rui Zhao <xiyuan(dot)zr(at)alibaba-inc(dot)com> wrote:
>> Prior to PG16, postmaster children would manually detach from shared memory
>> if it was not needed. However, this behavior was removed in fork mode in
>> commit aafc05d.
>
> Oh. The commit message makes no mention of that. I wonder whether it
> was inadvertent.
>
>> Detaching shared memory when it is no longer needed is beneficial, as
>> postmaster children (like syslogger) don't wish to take any risk of
>> accidentally corrupting shared memory. Additionally, any panic in these
>> processes will not reset shared memory.
>
> +1.
>
>> The attached patch addresses this issue by detaching shared memory after
>> fork_process().
>
> I don't know whether this is the correct approach or not, but
> hopefully Heikki can comment.

Good catch, it was not intentional. The patch looks good to me, so
committed. Thanks Rui!

--
Heikki Linnakangas
Neon (https://neon.tech)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-07-29 19:45:31 Re: tiny step toward threading: reduce dependence on setlocale()
Previous Message Robert Haas 2024-07-29 19:34:55 040_pg_createsubscriber.pl is slow and unstable (was Re: speed up a logical replica setup)