Re: pgsql: Add function to log the memory contexts of specified backend pro

From: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgsql: Add function to log the memory contexts of specified backend pro
Date: 2025-05-02 05:58:29
Message-ID: d7d7364d149587e5da2299f7acbc90dc@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 2025-05-02 09:02, Fujii Masao wrote:
> On 2025/05/02 2:27, Fujii Masao wrote:
>>
>>
>> On 2025/05/01 21:42, Robert Haas wrote:
>>> On Thu, May 1, 2025 at 3:53 AM Fujii Masao
>>> <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:
>>>> Just idea, what do you think about adding a flag to indicate whether
>>>> ProcessLogMemoryContextInterrupt() is currently running? Then,
>>>> when a backend receives a signal and
>>>> ProcessLogMemoryContextInterrupt()
>>>> is invoked, it can simply return immediately if the flag is already
>>>> set
>>>> like this:
>>>
>>> I think that something like this could work, but you would need more
>>> than this. Otherwise, if the function errors out, the flag would
>>> remain permanently set.
>>
>> Yes, we need to either use PG_TRY()/PG_FINALLY() or handle the flag as
>> a global variable and reset it in the error handling path. I think
>> using
>> PG_TRY()/PG_FINALLY() is the simpler option.
>
> I've implemented the patch in that way. Patch attached.

Thank you for the patch!

I confirmed that with this patch applied, the process no longer crashes
even after applying the change Robert used to trigger the crash.

a small nitpick:

+ * requested repeatedly and rapidly, potentially
leading to infinite

It looks like there are two spaces between "requested" and "repeatedly".

--
Regards,

--
Atsushi Torikoshi
Seconded from NTT DATA GROUP CORPORATION to SRA OSS K.K.

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2025-05-02 14:44:31 pgsql: Make "directory" setting work with extension_control_path
Previous Message Robins Tharakan 2025-05-02 04:02:15 Re: pgsql: doc: Warn that ts_headline() output is not HTML-safe.

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Dolgov 2025-05-02 07:13:39 Re: queryId constant squashing does not support prepared statements
Previous Message vignesh C 2025-05-02 05:22:43 Re: Add an option to skip loading missing publication to avoid logical replication failure