Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Naga Appani <nagnrik(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, Xuneng Zhou <xunengzhou(at)gmail(dot)com>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring
Date: 2025-12-29 03:51:23
Message-ID: aVH6u99shKNCoo0Y@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 25, 2025 at 10:30:37AM +0900, Michael Paquier wrote:
> I am wondering if it would not be cleaner and less confusing to do
> things slightly differently (sorry I did not pay much attention to
> that previously):
> - Change GetMultiXactInfo() to return two offsets, nextOffset and
> oldestOffset.
> - Use uint64 for members and recalculate the difference in
> MultiXactMemberFreezeThreshold() and the function code. Heikki has
> just switched multixact offsets to be 64 bits, yippee.
> - Redefine MultiXactMemberStorageSize() so as it does not take a
> number of members in input, but as the amount of space taken between
> two offsets. At least that would be more consistent with all the
> other inline functions of multixact.h that rely on MultiXactOffset
> inputs. Using a int64 is still OK I guess, there may be a case to
> detect "negative" numbers and give a change to the users of the new
> inline function to notice that they did a computation wrong, rather
> than hiding a signedness problem.

So, here is what I have in mind, split into independent pieces:
- Remove the existing type confusion with GetMultiXactInfo(), due to
how things have always been done in MultiXactMemberFreezeThreshold().
- Add macro MultiXactOffsetStorageSize(), to calculate the amount of
space used between two offsets.
- The main patch, with adjustments in comments, the test (no
non-ASCII characters in that, please). One thing that was really
surprising is that you did not consider ROLE_PG_READ_ALL_STATS. We
expect all the stats information to be hidden if a role is not granted
access to them, and this function should be no exception especially as
it relates to disk space usage like database or tablespace size
functions.

Anyway, attached are all these updated pieces. The doc edits are what
I have mentioned upthread, close to what you have suggested to me
offline.

Comments?
--
Michael

Attachment Content-Type Size
v14-0001-Rework-GetMultiXactInfo.patch text/x-diff 3.5 KB
v14-0002-Add-MultiXactOffsetStorageSize.patch text/x-diff 1.2 KB
v14-0003-Add-pg_get_multixact_stats-function-for-monitori.patch text/x-diff 18.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Tom Lane 2025-12-29 03:32:02 Re: cleanup: Split long Makefile lists across lines and sort them