Skip to content

Commit 9240a60

Browse files
author
Alexander Korotkov
committed
Fix handling of 64-bit page numbers in multixacts.
Also make multixacts initialize from non-zero page.
1 parent a79ec22 commit 9240a60

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/backend/access/transam/multixact.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
326326
static char *mxstatus_to_string(MultiXactStatus status);
327327

328328
/* management of SLRU infrastructure */
329-
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
330-
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
329+
static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
330+
static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
331331
static void ExtendMultiXactOffset(MultiXactId multi);
332332
static void ExtendMultiXactMember(MultiXactOffset offset, int nmembers);
333333
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
@@ -1674,25 +1674,45 @@ BootStrapMultiXact(void)
16741674
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE);
16751675

16761676
/* Create and zero the first page of the offsets log */
1677-
slotno = ZeroMultiXactOffsetPage(multiOffsetPageno, false);
1677+
slotno = ZeroMultiXactOffsetPage(0, false);
16781678

16791679
/* Make sure it's written out */
16801680
SimpleLruWritePage(MultiXactOffsetCtl, slotno);
16811681
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
16821682

1683+
if (multiOffsetPageno != 0)
1684+
{
1685+
/* Create and zero the first page of the offsets log */
1686+
slotno = ZeroMultiXactOffsetPage(multiOffsetPageno, false);
1687+
1688+
/* Make sure it's written out */
1689+
SimpleLruWritePage(MultiXactOffsetCtl, slotno);
1690+
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
1691+
}
1692+
16831693
LWLockRelease(MultiXactOffsetControlLock);
16841694

16851695
multiMemberPageno = MXOffsetToMemberPage(MultiXactState->nextOffset);
16861696

16871697
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
16881698

16891699
/* Create and zero the first page of the members log */
1690-
slotno = ZeroMultiXactMemberPage(multiMemberPageno, false);
1700+
slotno = ZeroMultiXactMemberPage(0, false);
16911701

16921702
/* Make sure it's written out */
16931703
SimpleLruWritePage(MultiXactMemberCtl, slotno);
16941704
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
16951705

1706+
if (multiMemberPageno != 0)
1707+
{
1708+
/* Create and zero the first page of the members log */
1709+
slotno = ZeroMultiXactMemberPage(multiMemberPageno, false);
1710+
1711+
/* Make sure it's written out */
1712+
SimpleLruWritePage(MultiXactMemberCtl, slotno);
1713+
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
1714+
}
1715+
16961716
LWLockRelease(MultiXactMemberControlLock);
16971717
}
16981718

@@ -1706,7 +1726,7 @@ BootStrapMultiXact(void)
17061726
* Control lock must be held at entry, and will be held at exit.
17071727
*/
17081728
static int
1709-
ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
1729+
ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
17101730
{
17111731
int slotno;
17121732

@@ -1722,7 +1742,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
17221742
* Ditto, for MultiXactMember
17231743
*/
17241744
static int
1725-
ZeroMultiXactMemberPage(int pageno, bool writeXlog)
1745+
ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
17261746
{
17271747
int slotno;
17281748

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy