Skip to content

Commit 594bac4

Browse files
committed
Fix WAL replay bug in the new GIN incomplete-split code.
Forgot to set the incomplete-split flag on the left page half, in redo of a page split. Spotted this by comparing the page contents on master and standby, after inserting/applying each WAL record.
1 parent 7d8f1de commit 594bac4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/backend/access/gin/ginxlog.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,9 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record)
461461
rbuffer;
462462
Page lpage,
463463
rpage;
464-
uint32 flags = 0;
464+
uint32 flags;
465+
uint32 lflags,
466+
rflags;
465467
char *payload;
466468
bool isLeaf = (data->flags & GIN_INSERT_ISLEAF) != 0;
467469
bool isData = (data->flags & GIN_INSERT_ISDATA) != 0;
@@ -481,22 +483,27 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record)
481483
ginRedoClearIncompleteSplit(lsn, data->node, data->leftChildBlkno);
482484
}
483485

486+
flags = 0;
484487
if (isLeaf)
485488
flags |= GIN_LEAF;
486489
if (isData)
487490
flags |= GIN_DATA;
488491
if (isLeaf && isData)
489492
flags |= GIN_COMPRESSED;
490493

494+
lflags = rflags = flags;
495+
if (!isRoot)
496+
lflags |= GIN_INCOMPLETE_SPLIT;
497+
491498
lbuffer = XLogReadBuffer(data->node, data->lblkno, true);
492499
Assert(BufferIsValid(lbuffer));
493500
lpage = (Page) BufferGetPage(lbuffer);
494-
GinInitBuffer(lbuffer, flags);
501+
GinInitBuffer(lbuffer, lflags);
495502

496503
rbuffer = XLogReadBuffer(data->node, data->rblkno, true);
497504
Assert(BufferIsValid(rbuffer));
498505
rpage = (Page) BufferGetPage(rbuffer);
499-
GinInitBuffer(rbuffer, flags);
506+
GinInitBuffer(rbuffer, rflags);
500507

501508
GinPageGetOpaque(lpage)->rightlink = BufferGetBlockNumber(rbuffer);
502509
GinPageGetOpaque(rpage)->rightlink = isRoot ? InvalidBlockNumber : data->rrlink;

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