Skip to content

Commit 2a114d0

Browse files
author
Alexander Korotkov
committed
More on 64-bit slru.
1 parent ae6a00c commit 2a114d0

File tree

7 files changed

+19
-42
lines changed

7 files changed

+19
-42
lines changed

src/backend/access/rmgrdesc/xlogdesc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
4444
CheckPoint *checkpoint = (CheckPoint *) rec;
4545

4646
appendStringInfo(buf, "redo %X/%X; "
47-
"tli %u; prev tli %u; fpw %s; xid " XID_FMT "; oid %u; multi " XID_FMT "; offset %u; "
47+
"tli %u; prev tli %u; fpw %s; xid " XID_FMT "; oid %u; multi " XID_FMT "; offset " INT64_FORMAT "; "
4848
"oldest xid " XID_FMT " in DB %u; oldest multi " XID_FMT " in DB %u; "
4949
"oldest/newest commit timestamp xid: " XID_FMT "/" XID_FMT "; "
5050
"oldest running xid " XID_FMT "; %s",

src/backend/access/transam/subtrans.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,6 @@ ExtendSUBTRANS(TransactionId newestXact)
339339
void
340340
TruncateSUBTRANS(TransactionId oldestXact)
341341
{
342-
int64 cutoffPage;
343-
344342
/*
345343
* The cutoff point is the start of the segment containing oldestXact. We
346344
* pass the *page* containing oldestXact to SimpleLruTruncate. We step
@@ -349,8 +347,16 @@ TruncateSUBTRANS(TransactionId oldestXact)
349347
* a page and oldestXact == next XID. In that case, if we didn't subtract
350348
* one, we'd trigger SimpleLruTruncate's wraparound detection.
351349
*/
352-
TransactionIdRetreat(oldestXact);
353-
cutoffPage = TransactionIdToPage(oldestXact);
350+
if (oldestXact > FirstNormalTransactionId)
351+
{
352+
int64 cutoffPage;
353+
TransactionIdRetreat(oldestXact);
354+
cutoffPage = TransactionIdToPage(oldestXact);
354355

355-
SimpleLruTruncate(SubTransCtl, cutoffPage);
356+
SimpleLruTruncate(SubTransCtl, cutoffPage);
357+
}
358+
else
359+
{
360+
SimpleLruTruncate(SubTransCtl, 0);
361+
}
356362
}

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6328,7 +6328,7 @@ StartupXLOG(void)
63286328
checkPoint.nextXid,
63296329
checkPoint.nextOid)));
63306330
ereport(DEBUG1,
6331-
(errmsg_internal("next MultiXactId: " XID_FMT "; next MultiXactOffset: %u",
6331+
(errmsg_internal("next MultiXactId: " XID_FMT "; next MultiXactOffset: " INT64_FORMAT,
63326332
checkPoint.nextMulti, checkPoint.nextMultiOffset)));
63336333
ereport(DEBUG1,
63346334
(errmsg_internal("oldest unfrozen transaction ID: " XID_FMT ", in database %u",

src/backend/commands/async.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ typedef struct QueuePosition
199199

200200
/* choose logically smaller QueuePosition */
201201
#define QUEUE_POS_MIN(x,y) \
202-
(asyncQueuePagePrecedes((x).page, (y).page) ? (x) : \
202+
(((x).page < (y).page) ? (x) : \
203203
(x).page != (y).page ? (y) : \
204204
(x).offset < (y).offset ? (x) : (y))
205205

206206
/* choose logically larger QueuePosition */
207207
#define QUEUE_POS_MAX(x,y) \
208-
(asyncQueuePagePrecedes((x).page, (y).page) ? (y) : \
208+
(((x).page < (y).page) ? (y) : \
209209
(x).page != (y).page ? (x) : \
210210
(x).offset > (y).offset ? (x) : (y))
211211

src/backend/storage/lmgr/predicate.c

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
416416
static void ReleaseRWConflict(RWConflict conflict);
417417
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
418418

419-
static bool OldSerXidPagePrecedesLogically(int p, int q);
420419
static void OldSerXidInit(void);
421420
static void OldSerXidAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
422421
static SerCommitSeqNo OldSerXidGetMinConflictCommitSeqNo(TransactionId xid);
@@ -756,32 +755,6 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
756755
}
757756
}
758757

759-
/*------------------------------------------------------------------------*/
760-
761-
/*
762-
* We will work on the page range of 0..OLDSERXID_MAX_PAGE.
763-
* Compares using wraparound logic, as is required by slru.c.
764-
*/
765-
static bool
766-
OldSerXidPagePrecedesLogically(int p, int q)
767-
{
768-
int diff;
769-
770-
/*
771-
* We have to compare modulo (OLDSERXID_MAX_PAGE+1)/2. Both inputs should
772-
* be in the range 0..OLDSERXID_MAX_PAGE.
773-
*/
774-
Assert(p >= 0 && p <= OLDSERXID_MAX_PAGE);
775-
Assert(q >= 0 && q <= OLDSERXID_MAX_PAGE);
776-
777-
diff = p - q;
778-
if (diff >= ((OLDSERXID_MAX_PAGE + 1) / 2))
779-
diff -= OLDSERXID_MAX_PAGE + 1;
780-
else if (diff < -((int) (OLDSERXID_MAX_PAGE + 1) / 2))
781-
diff += OLDSERXID_MAX_PAGE + 1;
782-
return diff < 0;
783-
}
784-
785758
/*
786759
* Initialize for the tracking of old serializable committed xids.
787760
*/
@@ -793,7 +766,6 @@ OldSerXidInit(void)
793766
/*
794767
* Set up SLRU management of the pg_serial data.
795768
*/
796-
OldSerXidSlruCtl->PagePrecedes = OldSerXidPagePrecedesLogically;
797769
SimpleLruInit(OldSerXidSlruCtl, "oldserxid",
798770
NUM_OLDSERXID_BUFFERS, 0, OldSerXidLock, "pg_serial",
799771
LWTRANCHE_OLDSERXID_BUFFERS);
@@ -860,8 +832,7 @@ OldSerXidAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
860832
else
861833
{
862834
firstZeroPage = OldSerXidNextPage(oldSerXidControl->headPage);
863-
isNewPage = OldSerXidPagePrecedesLogically(oldSerXidControl->headPage,
864-
targetPage);
835+
isNewPage = oldSerXidControl->headPage < targetPage;
865836
}
866837

867838
if (!TransactionIdIsValid(oldSerXidControl->headXid)

src/bin/pg_controldata/pg_controldata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ main(int argc, char *argv[])
220220
ControlFile->checkPointCopy.nextOid);
221221
printf(_("Latest checkpoint's NextMultiXactId: " XID_FMT "\n"),
222222
ControlFile->checkPointCopy.nextMulti);
223-
printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
223+
printf(_("Latest checkpoint's NextMultiOffset: " INT64_FORMAT "\n"),
224224
ControlFile->checkPointCopy.nextMultiOffset);
225225
printf(_("Latest checkpoint's oldestXID: " XID_FMT "\n"),
226226
ControlFile->checkPointCopy.oldestXid);

src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ PrintControlValues(bool guessed)
626626
ControlFile.checkPointCopy.nextOid);
627627
printf(_("Latest checkpoint's NextMultiXactId: " XID_FMT "\n"),
628628
ControlFile.checkPointCopy.nextMulti);
629-
printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
629+
printf(_("Latest checkpoint's NextMultiOffset: " INT64_FORMAT "\n"),
630630
ControlFile.checkPointCopy.nextMultiOffset);
631631
printf(_("Latest checkpoint's oldestXID: " XID_FMT "\n"),
632632
ControlFile.checkPointCopy.oldestXid);
@@ -698,7 +698,7 @@ PrintNewControlValues(void)
698698

699699
if (set_mxoff != -1)
700700
{
701-
printf(_("NextMultiOffset: %u\n"),
701+
printf(_("NextMultiOffset: " INT64_FORMAT "\n"),
702702
ControlFile.checkPointCopy.nextMultiOffset);
703703
}
704704

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