| From: | Naga Appani <nagnrik(at)gmail(dot)com> |
|---|---|
| To: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
| Cc: | Tomas Vondra <tomas(at)vondra(dot)me>, Xuneng Zhou <xunengzhou(at)gmail(dot)com>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, 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-13 19:34:47 |
| Message-ID: | CA+QeY+CqRjUj93_kV0YmMBqfkgo4WGEoiYOaP_wCMoJ8FOKpog@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Thank you, Ashutosh!
On Sun, Dec 7, 2025 at 10:40 PM Ashutosh Bapat
<ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
> The patch at [1] changes the function used to fetch mxid related
> information. With that we will get rid of awkwardness around
> non-availability of the statistics. It's better to wait for those
> changes to get committed before moving this forward.
Following the upstream change from Heikki's patch [0], I've updated
the patch (v12) to align with the new behavior.
Code changes:
- GetMultiXactInfo() now returns void, so the conditional checks and NULL
handling have been removed.
- MultiXactOffset is now 64-bit; updated the code to use Int64GetDatum()
for member counts.
- Switched to using MULTIXACT_MEMBERGROUP_SIZE and
MULTIXACT_MEMBERS_PER_MEMBERGROUP from multixact_internal.h instead of
hardcoded calculations.
Documentation changes:
- Removed the NULL-return discussion from func-info.sgml, as the
statistics are now always available.
- Updated maintenance.sgml to clarify that exceeding the historical
2^32 member limit no longer causes wraparound, but instead triggers
more aggressive vacuum activity for disk space management.
I validated the behavior before and after cleanup.
The function correctly reports current usage (beyond the old limits) and
resets once multixacts are removed:
postgres=# SELECT num_mxids, num_members, pg_size_pretty(members_size)
AS members_size, oldest_multixact FROM pg_get_multixact_stats();
-[ RECORD 1 ]------------------
num_mxids | 267969541
num_members | 9469693355
members_size | 44 GB
oldest_multixact | 2
postgres=# SELECT pg_terminate_backend(27222);
pg_terminate_backend
----------------------
t
postgres=# SELECT num_mxids, num_members, pg_size_pretty(members_size)
AS members_size, oldest_multixact FROM pg_get_multixact_stats();
-[ RECORD 1 ]------------------
num_mxids | 0
num_members | 0
members_size | 0 bytes
oldest_multixact | 267969543
The updated patch is attached.
Regards,
Naga
| Attachment | Content-Type | Size |
|---|---|---|
| v12-0001-Add-pg_get_multixact_stats-function-for-monitori.patch | application/octet-stream | 17.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Antonin Houska | 2025-12-13 19:39:21 | Re: Adding REPACK [concurrently] |
| Previous Message | Dharin Shah | 2025-12-13 19:32:27 | Re: [PATCH] Add zstd compression for TOAST using extended header format |