Re: Get memory contexts of an arbitrary backend process

From: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us, gkokolatos(at)protonmail(dot)com, kasahara(dot)tatsuhito(at)gmail(dot)com, craig(at)2ndquadrant(dot)com
Subject: Re: Get memory contexts of an arbitrary backend process
Date: 2021-03-31 06:02:02
Message-ID: f6f6373ae200c8a0e7466e4de9ca65eb@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-03-31 04:36, Fujii Masao wrote:
> On 2021/03/30 22:06, torikoshia wrote:
>> Modified the patch according to the suggestions.
>
> Thanks for updating the patch!
>
> I applied the cosmetic changes to the patch and added the example of
> the function call into the document. Attached is the updated version
> of the patch. Could you check this version?
>

Thanks a lot!

+The memory contexts will be logged in the log file. For example:

When 'log_destination = stderr' and 'logging_collector = off', it does
not log in the file but in the stderr.

Description like below would be a bit more accurate but I'm wondering
it's repeating the same words.

+ The memory contexts will be logged based on the log configuration set.
For example:

How do you think?

+<programlisting>
+postgres=# SELECT pg_log_backend_memory_contexts(pg_backend_pid());
+ pg_log_backend_memory_contexts
+--------------------------------
+ t
+(1 row)
+
+The memory contexts will be logged in the log file. For example:
+LOG: logging memory contexts of PID 10377
+STATEMENT: SELECT pg_log_backend_memory_contexts(pg_backend_pid());
+LOG: level: 0; TopMemoryContext: 80800 total in 6 blocks; 14432 free
(5 chunks); 66368 used
+LOG: level: 1; pgstat TabStatusArray lookup hash table: 8192 total in
1 blocks; 1408 free (0 chunks); 6784 used

The line "The memory contexts will be logged in the log file. For
example:"
is neither nor SQL command and its outputs, it might be better to
differentiate it.

What about the following like attached patch?

+<programlisting>
+postgres=# SELECT pg_log_backend_memory_contexts(pg_backend_pid());
+ pg_log_backend_memory_contexts
+--------------------------------
+ t
+(1 row)
+</programlisting>
+The memory contexts will be logged in the log file. For example:
+<screen>
+LOG: logging memory contexts of PID 10377
+STATEMENT: SELECT pg_log_backend_memory_contexts(pg_backend_pid());
+LOG: level: 0; TopMemoryContext: 80800 total in 6 blocks; 14432 free
(5 chunks); 66368 used
+LOG: level: 1; pgstat TabStatusArray lookup hash table: 8192 total in
1 blocks; 1408 free (0 chunks); 6784 used
...(snip)...
+LOG: level: 1; ErrorContext: 8192 total in 1 blocks; 7928 free (3
chunks); 264 used
+LOG: Grand total: 1651920 bytes in 201 blocks; 622360 free (88
chunks); 1029560 used
+</screen>

Regards.

Attachment Content-Type Size
v8-0001-add-memorycontext-elog-print.patch text/x-diff 26.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2021-03-31 06:02:12 Re: PostmasterIsAlive() in recovery (non-USE_POST_MASTER_DEATH_SIGNAL builds)
Previous Message Amit Kapila 2021-03-31 05:57:46 Re: extra semicolon in postgres_fdw test cases