From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: torikoshia <torikoshia@oss.nttdata.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Kasahara Tatsuhito <kasahara.tatsuhito@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Subject: Re: Creating a function for exposing memory usage of backend process
Date: Wed, 19 Aug 2020 11:01:37 -0400
Message-ID: <1414992.1597849297@sss.pgh.pa.us> (raw)
In-Reply-To: <20200819135545.GC19121@paquier.xyz>
References: <20200808014409.GA1600@paquier.xyz>
<66c9d45297ad820cd092b125aa91ce2c@oss.nttdata.com>
<98e53274-253f-6bd1-b542-489ecbda8753@oss.nttdata.com>
<083781e2-339e-9844-a02c-53a0ee3beb82@oss.nttdata.com>
<e687d9ec8ca6e7f387131a2455bc9e1f@oss.nttdata.com>
<34517933-7e90-f644-f606-86d7132b240b@oss.nttdata.com>
<0b339b06646e2c56a3aa081699322346@oss.nttdata.com>
<f1ae4071-31b8-d7aa-db5d-2781e5612e6f@oss.nttdata.com>
<261eebda3e1909475162b968e5a4ad2b@oss.nttdata.com>
<66ae5b88-208d-96fa-c20a-fb539b597859@oss.nttdata.com>
<20200819135545.GC19121@paquier.xyz>
Hadn't been paying attention to this thread up till now, but ...
Michael Paquier <michael@paquier.xyz> writes:
> By the way, I was looking at the code that has been committed, and I
> think that it is awkward to have a SQL function in mcxt.c, which is a
> rather low-level interface. I think that this new code should be
> moved to its own file, one suggestion for a location I have being
> src/backend/utils/adt/mcxtfuncs.c.
I agree with that, but I think this patch has a bigger problem:
why bother at all? It seems like a waste of code space and future
maintenance effort, because there is no use-case. In the situations
where you need to know where the memory went, you are almost never
in a position to leisurely execute a query and send the results over
to your client. This certainly would be useless to figure out why
an already-running query is eating space, for instance.
The only situation I could imagine where this would have any use is
where there is long-term (cross-query) bloat in, say, CacheMemoryContext
--- but it's not even very helpful for that, since you can't examine
anything finer-grain than a memory context. Plus you need to be
running an interactive session, or else be willing to hack up your
application to try to get it to inspect the view (and log the
results somewhere) at useful times.
On top of all that, the functionality has Heisenberg problems,
because simply using it changes what you are trying to observe,
in complex and undocumented ways (not that the documentation
would be of any use to non-experts anyway).
My own thoughts about improving the debugging situation would've been
to create a way to send a signal to a session to make it dump its
current memory map to the postmaster log (not the client, since the
client is unlikely to be prepared to receive anything extraneous).
But this is nothing like that.
Given the lack of clear use-case, and the possibility (admittedly
not strong) that this is still somehow a security hazard, I think
we should revert it. If it stays, I'd like to see restrictions
on who can read the view.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, michael@paquier.xyz, masao.fujii@oss.nttdata.com, torikoshia@oss.nttdata.com, robertmhaas@gmail.com, kasahara.tatsuhito@gmail.com, andres@anarazel.de
Subject: Re: Creating a function for exposing memory usage of backend process
In-Reply-To: <1414992.1597849297@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox