Re: Get memory contexts of an arbitrary backend process

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, Zhihong Yu <zyu(at)yugabyte(dot)com>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, gkokolatos(at)protonmail(dot)com, kasahara(dot)tatsuhito(at)gmail(dot)com, Craig Ringer <craig(at)2ndquadrant(dot)com>
Subject: Re: Get memory contexts of an arbitrary backend process
Date: 2021-04-05 15:08:46
Message-ID: c899e0d4-ac82-1f4e-bbd3-41c40b33f0e9@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021/04/05 21:03, torikoshia wrote:
> On 2021-04-05 12:59, Fujii Masao wrote:
>> On 2021/04/05 12:20, Zhihong Yu wrote:
>
> Thanks for reviewing!
>
>>> + * On receipt of this signal, a backend sets the flag in the signal
>>> + * handler, and then which causes the next CHECK_FOR_INTERRUPTS()
>
>>> I think the 'and then' is not needed:
>
> Although I wonder either would be fine, removed the words.
>
>>> +        * This is just a warning so a loop-through-resultset will not abort
>>> +        * if one backend logged its memory contexts during the run.
>>>
>>> The pid given by arg 0 is not a PostgreSQL server process. Which other backend could it be ?
>>
>> This is the comment that I added wrongly. So the comment should be
>> "This is just a warning so a loop-through-resultset will not abort
>> if one backend terminated on its own during the run.",
>> like pg_signal_backend(). Thought?
>
> +1.
>
> Attached v10 patch.

Thanks for updating the patch!

I updated the patch as follows. Could you check the attached patch?

+ Memory contexts will be logged based on the log configuration set.
+ See <xref linkend="runtime-config-logging"/> for more information.

Those memory contexts are logged at LOG level, but they are not sent to
a client whatever the setting of client_min_messages. I think
this information should be documented. So I updated the document as follows.

These memory contexts will be logged at <literal>LOG</literal>
message level. They will appear in the server log based on
the log configuration set (See <xref linkend="runtime-config-logging"/>
for more information), but will not be sent to the client whatever
the setting of <xref linkend="guc-client-min-messages"/>.

+ Only superusers can log the memory contexts.

We can read this description as "only superusers can request to log ...".
But ISTM that we can also read this as "only superusers can log (dump)
the memory contexts of its backend". Right? To avoid this confusion,
I updated this description as follows.

Only superusers can request to log the memory contexts.

I added the following note about the performance overhead by this function.

Note that frequent calls to this function could incur significant overhead,
because it may generate a large number of log messages.

I also added some comments.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
v11-0001-add-memorycontext-elog-print.patch text/plain 28.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kazutaka Onishi 2021-04-05 15:17:22 Re: TRUNCATE on foreign table
Previous Message osumi.takamichi@fujitsu.com 2021-04-05 14:54:13 RE: Stronger safeguard for archive recovery not to miss data