Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita50d976

Browse files
committed
Wrap multixact/members correctly during extension
In the 9.2 code for extending multixact/members, the logic was verysimple because the number of entries in a members page was a properdivisor of 2^32, and thus at 2^32 wraparound the logic for page switchwas identical than at any other page boundary. In commit0ac5ad5 Ifailed to realize this and introduced code that was not able to go overthe 2^32 boundary. Fix that by ensuring that when we reach the lastpage of the last segment we correctly zero the initial page of theinitial segment, using correct uint32-wraparound-safe arithmetic.Noticed while investigating bug #8673 reported by Serge Negodyuck, asdiagnosed by Andres Freund.
1 parent722acf5 commita50d976

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

‎src/backend/access/transam/multixact.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,7 +2259,6 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
22592259
{
22602260
intflagsoff;
22612261
intflagsbit;
2262-
intdifference;
22632262

22642263
/*
22652264
* Only zero when at first entry of a page.
@@ -2280,10 +2279,25 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
22802279
LWLockRelease(MultiXactMemberControlLock);
22812280
}
22822281

2283-
/* Advance to next page (OK if nmembers goes negative) */
2284-
difference=MULTIXACT_MEMBERS_PER_PAGE-offset %MULTIXACT_MEMBERS_PER_PAGE;
2285-
offset+=difference;
2286-
nmembers-=difference;
2282+
/*
2283+
* Advance to next page, taking care to properly handle the wraparound
2284+
* case. OK if nmembers goes negative.
2285+
*/
2286+
if ((unsignedint) (offset+nmembers)<offset)
2287+
{
2288+
uint32difference=offset+MULTIXACT_MEMBERS_PER_PAGE;
2289+
2290+
nmembers-= (unsignedint) (MULTIXACT_MEMBERS_PER_PAGE-difference);
2291+
offset=0;
2292+
}
2293+
else
2294+
{
2295+
intdifference;
2296+
2297+
difference=MULTIXACT_MEMBERS_PER_PAGE-offset %MULTIXACT_MEMBERS_PER_PAGE;
2298+
nmembers-=difference;
2299+
offset+=difference;
2300+
}
22872301
}
22882302
}
22892303

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp