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 <nagnrik@gmail.com>
Discussion: https://postgr.es/m/aUyTvZMq2CLgNEB4@paquier.xyz
This commit is contained in:
Michael Paquier 2025-12-30 14:03:49 +09:00
parent 7da9d8f2db
commit 9cf746a453
2 changed files with 9 additions and 9 deletions

View File

@ -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)

View File

@ -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);