Skip to content

Commit 5e6641b

Browse files
author
Alexander Korotkov
committed
Fix bug while form toast tuple. Also make support of arbitratry initial values for SLRU.
1 parent f255954 commit 5e6641b

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

src/backend/access/heap/tuptoaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
10261026
result_tuple->t_len = new_tuple_len;
10271027
result_tuple->t_self = newtup->t_self;
10281028
result_tuple->t_tableOid = newtup->t_tableOid;
1029-
HeapTupleSetInvalidEpoch(result_tuple);
1029+
HeapTupleCopyEpoch(result_tuple, newtup);
10301030
new_data = (HeapTupleHeader) ((char *) result_tuple + HEAPTUPLESIZE);
10311031
result_tuple->t_data = new_data;
10321032

src/backend/access/transam/clog.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ void
461461
BootStrapCLOG(void)
462462
{
463463
int slotno;
464+
int64 pageno;
465+
466+
pageno = TransactionIdToPage(ShmemVariableCache->nextXid);
464467

465468
LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
466469

@@ -471,6 +474,16 @@ BootStrapCLOG(void)
471474
SimpleLruWritePage(ClogCtl, slotno);
472475
Assert(!ClogCtl->shared->page_dirty[slotno]);
473476

477+
if (pageno != 0)
478+
{
479+
/* Create and zero the first page of the commit log */
480+
slotno = ZeroCLOGPage(pageno, false);
481+
482+
/* Make sure it's written out */
483+
SimpleLruWritePage(ClogCtl, slotno);
484+
Assert(!ClogCtl->shared->page_dirty[slotno]);
485+
}
486+
474487
LWLockRelease(CLogControlLock);
475488
}
476489

src/backend/access/transam/multixact.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,22 +1666,28 @@ void
16661666
BootStrapMultiXact(void)
16671667
{
16681668
int slotno;
1669+
int64 multiOffsetPageno;
1670+
int64 multiMemberPageno;
1671+
1672+
multiOffsetPageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
16691673

16701674
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE);
16711675

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

16751679
/* Make sure it's written out */
16761680
SimpleLruWritePage(MultiXactOffsetCtl, slotno);
16771681
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
16781682

16791683
LWLockRelease(MultiXactOffsetControlLock);
16801684

1685+
multiMemberPageno = MXOffsetToMemberPage(MultiXactState->nextOffset);
1686+
16811687
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
16821688

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

16861692
/* Make sure it's written out */
16871693
SimpleLruWritePage(MultiXactMemberCtl, slotno);

src/backend/access/transam/subtrans.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,14 @@ void
198198
BootStrapSUBTRANS(void)
199199
{
200200
int slotno;
201+
int64 pageno;
202+
203+
pageno = TransactionIdToPage(ShmemVariableCache->nextXid);
201204

202205
LWLockAcquire(SubtransControlLock, LW_EXCLUSIVE);
203206

204207
/* Create and zero the first page of the subtrans log */
205-
slotno = ZeroSUBTRANSPage(0);
208+
slotno = ZeroSUBTRANSPage(pageno);
206209

207210
/* Make sure it's written out */
208211
SimpleLruWritePage(SubTransCtl, slotno);

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4806,13 +4806,12 @@ BootStrapXLOG(void)
48064806
checkPoint.ThisTimeLineID = ThisTimeLineID;
48074807
checkPoint.PrevTimeLineID = ThisTimeLineID;
48084808
checkPoint.fullPageWrites = fullPageWrites;
4809-
checkPoint.nextXid = FirstNormalTransactionId;
4810-
TransactionIdAdvance(checkPoint.nextXid);
4809+
checkPoint.nextXid = FirstNormalTransactionId + 1;
48114810
checkPoint.nextOid = FirstBootstrapObjectId;
48124811
checkPoint.nextMulti = FirstMultiXactId;
48134812
checkPoint.nextMultiOffset = 0;
48144813
checkPoint.nextMulti++;
4815-
checkPoint.oldestXid = FirstNormalTransactionId;
4814+
checkPoint.oldestXid = checkPoint.nextXid - 1;
48164815
checkPoint.oldestXidDB = TemplateDbOid;
48174816
checkPoint.oldestMulti = FirstMultiXactId;
48184817
checkPoint.oldestMultiDB = TemplateDbOid;

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