| From: | Naga Appani <nagnrik(at)gmail(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| 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-30 02:57:11 |
| Message-ID: | CA+QeY+Bjbe8GuNYaDDHMAYJMoR9F+R7xLKWsUTjJrcxfzs_cZA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sun, Dec 28, 2025 at 9:51 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> 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
Thank you for patches, Michael! I've tested and everything works well:
- All patches apply cleanly
- Isolation test (multixact-stats) passes
- Function correctly reports stats under heavy load
Tested with significant multixact activity:
++++++++++++++++++++++++++++++++++++++++++++++
postgres=# \x
Expanded display is on.
postgres=# SELECT
to_char(num_mxids::bigint, 'FM999,999,999,999') AS num_mxids,
to_char(num_members::bigint, 'FM999,999,999,999') AS num_members,
to_char(members_size::bigint, 'FM999,999,999,999') AS members_size_bytes,
pg_size_pretty(members_size) AS members_size_pretty,
to_char(oldest_multixact::text::bigint, 'FM999,999,999,999') AS
oldest_multixact
FROM pg_get_multixact_stats();
-[ RECORD 1 ]-------+------------------
num_mxids | 235,095,556
num_members | 14,435,701,862
members_size_bytes | 72,178,509,300
members_size_pretty | 67 GB
oldest_multixact | 2
++++++++++++++++++++++++++++++++++++++++++++++
After cleanup, the function properly resets:
++++++++++++++++++++++++++++++++++++++++++++++
-[ RECORD 1 ]-------+-------------
num_mxids | 0
num_members | 0
members_size_bytes | 0
members_size_pretty | 0 bytes
oldest_multixact | 235,095,558
++++++++++++++++++++++++++++++++++++++++++++++
The oldest_multixact correctly advances to reflect the cleanup.
Thanks for adding the pg_read_all_stats privilege check!
I think this is ready for RFC.
Best regards,
Naga
| From | Date | Subject | |
|---|---|---|---|
| Next Message | cca5507 | 2025-12-30 02:57:46 | Re: [BUG] Incorrect historic snapshot may be serialized to diskduring fast-forwarding |
| Previous Message | Xuneng Zhou | 2025-12-30 02:43:17 | Re: Streamify more code paths |