From: Michael Paquier Date: Tue, 30 Dec 2025 05:03:49 +0000 (+0900) Subject: Change GetMultiXactInfo() to return the next multixact offset X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cf746a453c15ffdf652a6d50683bfd82e654950;p=thirdparty%2Fpostgresql.git Change GetMultiXactInfo() to return the next multixact offset This routine returned a number of members as a MultiXactOffset, calculated based on the difference between the next-to-be-assigned offset and the oldest offset. However, this number is not actually an offset but a number. This type confusion comes from the original implementation of MultiXactMemberFreezeThreshold(), in 53bb309d2d5a. The number of members is now defined as a uint64, large enough for MultiXactOffset. This change will be used in a follow-up patch. Reviewed-by: Naga Appani Discussion: https://postgr.es/m/aUyTvZMq2CLgNEB4@paquier.xyz --- diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 34956a5a663..0d6f594e2a0 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -2461,25 +2461,23 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result) * * Returns information about the current MultiXact state, as of: * multixacts: Number of MultiXacts (nextMultiXactId - oldestMultiXactId) - * members: Number of member entries (nextOffset - oldestOffset) + * nextOffset: Next-to-be-assigned offset * oldestMultiXactId: Oldest MultiXact ID still in use * oldestOffset: Oldest offset still in use */ void -GetMultiXactInfo(uint32 *multixacts, MultiXactOffset *members, +GetMultiXactInfo(uint32 *multixacts, MultiXactOffset *nextOffset, MultiXactId *oldestMultiXactId, MultiXactOffset *oldestOffset) { - MultiXactOffset nextOffset; MultiXactId nextMultiXactId; LWLockAcquire(MultiXactGenLock, LW_SHARED); - nextOffset = MultiXactState->nextOffset; + *nextOffset = MultiXactState->nextOffset; *oldestMultiXactId = MultiXactState->oldestMultiXactId; nextMultiXactId = MultiXactState->nextMXact; *oldestOffset = MultiXactState->oldestOffset; LWLockRelease(MultiXactGenLock); - *members = nextOffset - *oldestOffset; *multixacts = nextMultiXactId - *oldestMultiXactId; } @@ -2514,16 +2512,18 @@ GetMultiXactInfo(uint32 *multixacts, MultiXactOffset *members, int MultiXactMemberFreezeThreshold(void) { - MultiXactOffset members; uint32 multixacts; uint32 victim_multixacts; double fraction; int result; MultiXactId oldestMultiXactId; MultiXactOffset oldestOffset; + MultiXactOffset nextOffset; + uint64 members; - /* Read the current offsets and members usage. */ - GetMultiXactInfo(&multixacts, &members, &oldestMultiXactId, &oldestOffset); + /* Read the current offsets and multixact usage. */ + GetMultiXactInfo(&multixacts, &nextOffset, &oldestMultiXactId, &oldestOffset); + members = nextOffset - oldestOffset; /* If member space utilization is low, no special action is required. */ if (members <= MULTIXACT_MEMBER_LOW_THRESHOLD) diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h index 6433fe16364..d22abbb7251 100644 --- a/src/include/access/multixact.h +++ b/src/include/access/multixact.h @@ -109,7 +109,7 @@ extern bool MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly); extern void MultiXactIdSetOldestMember(void); extern int GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members, bool from_pgupgrade, bool isLockOnly); -extern void GetMultiXactInfo(uint32 *multixacts, MultiXactOffset *members, +extern void GetMultiXactInfo(uint32 *multixacts, MultiXactOffset *nextOffset, MultiXactId *oldestMultiXactId, MultiXactOffset *oldestOffset); extern bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2);