Skip to content

Commit ae6a00c

Browse files
author
Alexander Korotkov
committed
Some work on 64-bit slru.
1 parent 8b2162a commit ae6a00c

File tree

13 files changed

+180
-885
lines changed

13 files changed

+180
-885
lines changed

src/backend/access/rmgrdesc/clogdesc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ clog_desc(StringInfo buf, XLogReaderState *record)
2525

2626
if (info == CLOG_ZEROPAGE || info == CLOG_TRUNCATE)
2727
{
28-
int pageno;
28+
int64 pageno;
2929

30-
memcpy(&pageno, rec, sizeof(int));
31-
appendStringInfo(buf, "%d", pageno);
30+
memcpy(&pageno, rec, sizeof(int64));
31+
appendStringInfo(buf, INT64_FORMAT, pageno);
3232
}
3333
}
3434

src/backend/access/rmgrdesc/mxactdesc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,26 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
5555
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
5656
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
5757
{
58-
int pageno;
58+
int64 pageno;
5959

6060
memcpy(&pageno, rec, sizeof(int));
61-
appendStringInfo(buf, "%d", pageno);
61+
appendStringInfo(buf, INT64_FORMAT, pageno);
6262
}
6363
else if (info == XLOG_MULTIXACT_CREATE_ID)
6464
{
6565
xl_multixact_create *xlrec = (xl_multixact_create *) rec;
6666
int i;
6767

68-
appendStringInfo(buf, XID_FMT " offset %u nmembers %d: ", xlrec->mid,
69-
xlrec->moff, xlrec->nmembers);
68+
appendStringInfo(buf, XID_FMT " offset " INT64_FORMAT " nmembers %d: ",
69+
xlrec->mid, xlrec->moff, xlrec->nmembers);
7070
for (i = 0; i < xlrec->nmembers; i++)
7171
out_member(buf, &xlrec->members[i]);
7272
}
7373
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
7474
{
7575
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
7676

77-
appendStringInfo(buf, "offsets [" XID_FMT ", " XID_FMT "), members [%u, %u)",
77+
appendStringInfo(buf, "offsets [" XID_FMT ", " XID_FMT "), members [" INT64_FORMAT ", " INT64_FORMAT ")",
7878
xlrec->startTruncOff, xlrec->endTruncOff,
7979
xlrec->startTruncMemb, xlrec->endTruncMemb);
8080
}

src/backend/access/transam/clog.c

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,12 @@ static SlruCtlData ClogCtlData;
8080
#define ClogCtl (&ClogCtlData)
8181

8282

83-
static int ZeroCLOGPage(int pageno, bool writeXlog);
84-
static bool CLOGPagePrecedes(int page1, int page2);
85-
static void WriteZeroPageXlogRec(int pageno);
86-
static void WriteTruncateXlogRec(int pageno);
83+
static int ZeroCLOGPage(int64 pageno, bool writeXlog);
84+
static void WriteZeroPageXlogRec(int64 pageno);
85+
static void WriteTruncateXlogRec(int64 pageno);
8786
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
8887
TransactionId *subxids, XidStatus status,
89-
XLogRecPtr lsn, int pageno);
88+
XLogRecPtr lsn, int64 pageno);
9089
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
9190
XLogRecPtr lsn, int slotno);
9291
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
@@ -148,7 +147,7 @@ void
148147
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
149148
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
150149
{
151-
int pageno = TransactionIdToPage(xid); /* get page of parent */
150+
int64 pageno = TransactionIdToPage(xid); /* get page of parent */
152151
int i;
153152

154153
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -222,7 +221,7 @@ static void
222221
set_status_by_pages(int nsubxids, TransactionId *subxids,
223222
XidStatus status, XLogRecPtr lsn)
224223
{
225-
int pageno = TransactionIdToPage(subxids[0]);
224+
int64 pageno = TransactionIdToPage(subxids[0]);
226225
int offset = 0;
227226
int i = 0;
228227

@@ -253,7 +252,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
253252
static void
254253
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
255254
TransactionId *subxids, XidStatus status,
256-
XLogRecPtr lsn, int pageno)
255+
XLogRecPtr lsn, int64 pageno)
257256
{
258257
int slotno;
259258
int i;
@@ -391,7 +390,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
391390
XidStatus
392391
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
393392
{
394-
int pageno = TransactionIdToPage(xid);
393+
int64 pageno = TransactionIdToPage(xid);
395394
int byteno = TransactionIdToByte(xid);
396395
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
397396
int slotno;
@@ -448,7 +447,6 @@ CLOGShmemSize(void)
448447
void
449448
CLOGShmemInit(void)
450449
{
451-
ClogCtl->PagePrecedes = CLOGPagePrecedes;
452450
SimpleLruInit(ClogCtl, "clog", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
453451
CLogControlLock, "pg_clog", LWTRANCHE_CLOG_BUFFERS);
454452
}
@@ -486,7 +484,7 @@ BootStrapCLOG(void)
486484
* Control lock must be held at entry, and will be held at exit.
487485
*/
488486
static int
489-
ZeroCLOGPage(int pageno, bool writeXlog)
487+
ZeroCLOGPage(int64 pageno, bool writeXlog)
490488
{
491489
int slotno;
492490

@@ -506,7 +504,7 @@ void
506504
StartupCLOG(void)
507505
{
508506
TransactionId xid = ShmemVariableCache->nextXid;
509-
int pageno = TransactionIdToPage(xid);
507+
int64 pageno = TransactionIdToPage(xid);
510508

511509
LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
512510

@@ -525,7 +523,7 @@ void
525523
TrimCLOG(void)
526524
{
527525
TransactionId xid = ShmemVariableCache->nextXid;
528-
int pageno = TransactionIdToPage(xid);
526+
int64 pageno = TransactionIdToPage(xid);
529527

530528
LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
531529

@@ -603,7 +601,7 @@ CheckPointCLOG(void)
603601
void
604602
ExtendCLOG(TransactionId newestXact)
605603
{
606-
int pageno;
604+
int64 pageno;
607605

608606
/*
609607
* No work except at first XID of a page. But beware: just after
@@ -642,7 +640,7 @@ ExtendCLOG(TransactionId newestXact)
642640
void
643641
TruncateCLOG(TransactionId oldestXact)
644642
{
645-
int cutoffPage;
643+
int64 cutoffPage;
646644

647645
/*
648646
* The cutoff point is the start of the segment containing oldestXact. We
@@ -661,39 +659,14 @@ TruncateCLOG(TransactionId oldestXact)
661659
SimpleLruTruncate(ClogCtl, cutoffPage);
662660
}
663661

664-
665-
/*
666-
* Decide which of two CLOG page numbers is "older" for truncation purposes.
667-
*
668-
* We need to use comparison of TransactionIds here in order to do the right
669-
* thing with wraparound XID arithmetic. However, if we are asked about
670-
* page number zero, we don't want to hand InvalidTransactionId to
671-
* TransactionIdPrecedes: it'll get weird about permanent xact IDs. So,
672-
* offset both xids by FirstNormalTransactionId to avoid that.
673-
*/
674-
static bool
675-
CLOGPagePrecedes(int page1, int page2)
676-
{
677-
TransactionId xid1;
678-
TransactionId xid2;
679-
680-
xid1 = ((TransactionId) page1) * CLOG_XACTS_PER_PAGE;
681-
xid1 += FirstNormalTransactionId;
682-
xid2 = ((TransactionId) page2) * CLOG_XACTS_PER_PAGE;
683-
xid2 += FirstNormalTransactionId;
684-
685-
return TransactionIdPrecedes(xid1, xid2);
686-
}
687-
688-
689662
/*
690663
* Write a ZEROPAGE xlog record
691664
*/
692665
static void
693-
WriteZeroPageXlogRec(int pageno)
666+
WriteZeroPageXlogRec(int64 pageno)
694667
{
695668
XLogBeginInsert();
696-
XLogRegisterData((char *) (&pageno), sizeof(int));
669+
XLogRegisterData((char *) (&pageno), sizeof(int64));
697670
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
698671
}
699672

@@ -704,12 +677,12 @@ WriteZeroPageXlogRec(int pageno)
704677
* in TruncateCLOG().
705678
*/
706679
static void
707-
WriteTruncateXlogRec(int pageno)
680+
WriteTruncateXlogRec(int64 pageno)
708681
{
709682
XLogRecPtr recptr;
710683

711684
XLogBeginInsert();
712-
XLogRegisterData((char *) (&pageno), sizeof(int));
685+
XLogRegisterData((char *) (&pageno), sizeof(int64));
713686
recptr = XLogInsert(RM_CLOG_ID, CLOG_TRUNCATE);
714687
XLogFlush(recptr);
715688
}
@@ -727,10 +700,10 @@ clog_redo(XLogReaderState *record)
727700

728701
if (info == CLOG_ZEROPAGE)
729702
{
730-
int pageno;
703+
int64 pageno;
731704
int slotno;
732705

733-
memcpy(&pageno, XLogRecGetData(record), sizeof(int));
706+
memcpy(&pageno, XLogRecGetData(record), sizeof(int64));
734707

735708
LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
736709

@@ -742,9 +715,9 @@ clog_redo(XLogReaderState *record)
742715
}
743716
else if (info == CLOG_TRUNCATE)
744717
{
745-
int pageno;
718+
int64 pageno;
746719

747-
memcpy(&pageno, XLogRecGetData(record), sizeof(int));
720+
memcpy(&pageno, XLogRecGetData(record), sizeof(int64));
748721

749722
/*
750723
* During XLOG replay, latest_page_number isn't set up yet; insert a

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