]> granicus.if.org Git - postgresql/commitdiff
Fix WAL replay bug in the new GIN incomplete-split code.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 7 Apr 2014 11:34:31 +0000 (14:34 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 7 Apr 2014 11:37:30 +0000 (14:37 +0300)
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.

src/backend/access/gin/ginxlog.c

index f65a98d95ff31b976b3dee73dee2af8fd52d56de..a263a1350cf10fe49fc3cd993e310269bead7ae5 100644 (file)
@@ -461,7 +461,9 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record)
                                rbuffer;
        Page            lpage,
                                rpage;
-       uint32          flags = 0;
+       uint32          flags;
+       uint32          lflags,
+                               rflags;
        char       *payload;
        bool            isLeaf = (data->flags & GIN_INSERT_ISLEAF) != 0;
        bool            isData = (data->flags & GIN_INSERT_ISDATA) != 0;
@@ -481,6 +483,7 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record)
                        ginRedoClearIncompleteSplit(lsn, data->node, data->leftChildBlkno);
        }
 
+       flags = 0;
        if (isLeaf)
                flags |= GIN_LEAF;
        if (isData)
@@ -488,15 +491,19 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record)
        if (isLeaf && isData)
                flags |= GIN_COMPRESSED;
 
+       lflags = rflags = flags;
+       if (!isRoot)
+               lflags |= GIN_INCOMPLETE_SPLIT;
+
        lbuffer = XLogReadBuffer(data->node, data->lblkno, true);
        Assert(BufferIsValid(lbuffer));
        lpage = (Page) BufferGetPage(lbuffer);
-       GinInitBuffer(lbuffer, flags);
+       GinInitBuffer(lbuffer, lflags);
 
        rbuffer = XLogReadBuffer(data->node, data->rblkno, true);
        Assert(BufferIsValid(rbuffer));
        rpage = (Page) BufferGetPage(rbuffer);
-       GinInitBuffer(rbuffer, flags);
+       GinInitBuffer(rbuffer, rflags);
 
        GinPageGetOpaque(lpage)->rightlink = BufferGetBlockNumber(rbuffer);
        GinPageGetOpaque(rpage)->rightlink = isRoot ? InvalidBlockNumber : data->rrlink;