Commit f7442628 authored by Teodor Sigaev's avatar Teodor Sigaev

Move call of MarkBufferDirty() before XLogInsert() as required.

Many thanks to Heikki Linnakangas <heikki@enterprisedb.com> for his
sharp eyes.
parent 4c0fe512
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gin/ginbtree.c,v 1.8 2007/02/01 04:16:07 neilc Exp $
* $PostgreSQL: pgsql/src/backend/access/gin/ginbtree.c,v 1.9 2007/06/05 12:47:49 teodor Exp $
*-------------------------------------------------------------------------
*/
......@@ -294,6 +294,8 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack)
START_CRIT_SECTION();
btree->placeToPage(btree, stack->buffer, stack->off, &rdata);
MarkBufferDirty(stack->buffer);
if (!btree->index->rd_istemp)
{
XLogRecPtr recptr;
......@@ -303,7 +305,6 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack)
PageSetTLI(page, ThisTimeLineID);
}
MarkBufferDirty(stack->buffer);
UnlockReleaseBuffer(stack->buffer);
END_CRIT_SECTION();
......@@ -351,6 +352,11 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack)
GinInitBuffer(stack->buffer, GinPageGetOpaque(newlpage)->flags & ~GIN_LEAF);
PageRestoreTempPage(newlpage, lpage);
btree->fillRoot(btree, stack->buffer, lbuffer, rbuffer);
MarkBufferDirty(rbuffer);
MarkBufferDirty(lbuffer);
MarkBufferDirty(stack->buffer);
if (!btree->index->rd_istemp)
{
XLogRecPtr recptr;
......@@ -364,11 +370,8 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack)
PageSetTLI(rpage, ThisTimeLineID);
}
MarkBufferDirty(rbuffer);
UnlockReleaseBuffer(rbuffer);
MarkBufferDirty(lbuffer);
UnlockReleaseBuffer(lbuffer);
MarkBufferDirty(stack->buffer);
UnlockReleaseBuffer(stack->buffer);
END_CRIT_SECTION();
......@@ -389,6 +392,10 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack)
START_CRIT_SECTION();
PageRestoreTempPage(newlpage, lpage);
MarkBufferDirty(rbuffer);
MarkBufferDirty(stack->buffer);
if (!btree->index->rd_istemp)
{
XLogRecPtr recptr;
......@@ -399,9 +406,7 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack)
PageSetLSN(rpage, recptr);
PageSetTLI(rpage, ThisTimeLineID);
}
MarkBufferDirty(rbuffer);
UnlockReleaseBuffer(rbuffer);
MarkBufferDirty(stack->buffer);
END_CRIT_SECTION();
}
}
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.8 2007/02/01 04:16:08 neilc Exp $
* $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.9 2007/06/05 12:47:49 teodor Exp $
*-------------------------------------------------------------------------
*/
......@@ -48,6 +48,8 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems)
memcpy(GinDataPageGetData(page), items, sizeof(ItemPointerData) * nitems);
GinPageGetOpaque(page)->maxoff = nitems;
MarkBufferDirty(buffer);
if (!index->rd_istemp)
{
XLogRecPtr recptr;
......@@ -76,7 +78,6 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems)
}
MarkBufferDirty(buffer);
UnlockReleaseBuffer(buffer);
END_CRIT_SECTION();
......@@ -281,6 +282,8 @@ ginbuild(PG_FUNCTION_ARGS)
buffer = GinNewBuffer(index);
START_CRIT_SECTION();
GinInitBuffer(buffer, GIN_LEAF);
MarkBufferDirty(buffer);
if (!index->rd_istemp)
{
XLogRecPtr recptr;
......@@ -301,7 +304,6 @@ ginbuild(PG_FUNCTION_ARGS)
}
MarkBufferDirty(buffer);
UnlockReleaseBuffer(buffer);
END_CRIT_SECTION();
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.14 2007/06/04 15:56:28 teodor Exp $
* $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.15 2007/06/05 12:47:49 teodor Exp $
*-------------------------------------------------------------------------
*/
......@@ -191,9 +191,9 @@ ginVacuumPostingTreeLeaves(GinVacuumState *gvs, BlockNumber blkno, bool isRoot,
pfree(cleaned);
GinPageGetOpaque(page)->maxoff = newMaxOff;
MarkBufferDirty(buffer);
xlogVacuumPage(gvs->index, buffer);
MarkBufferDirty(buffer);
END_CRIT_SECTION();
/* if root is a leaf page, we don't desire further processing */
......@@ -282,6 +282,11 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn
*/
GinPageGetOpaque(page)->flags = GIN_DELETED;
MarkBufferDirty(pBuffer);
if (leftBlkno != InvalidBlockNumber)
MarkBufferDirty(lBuffer);
MarkBufferDirty(dBuffer);
if (!gvs->index->rd_istemp)
{
XLogRecPtr recptr;
......@@ -339,18 +344,13 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn
}
}
MarkBufferDirty(pBuffer);
if (!isParentRoot)
LockBuffer(pBuffer, GIN_UNLOCK);
ReleaseBuffer(pBuffer);
if (leftBlkno != InvalidBlockNumber)
{
MarkBufferDirty(lBuffer);
UnlockReleaseBuffer(lBuffer);
}
MarkBufferDirty(dBuffer);
UnlockReleaseBuffer(dBuffer);
END_CRIT_SECTION();
......@@ -636,8 +636,8 @@ ginbulkdelete(PG_FUNCTION_ARGS)
{
START_CRIT_SECTION();
PageRestoreTempPage(resPage, page);
xlogVacuumPage(gvs.index, buffer);
MarkBufferDirty(buffer);
xlogVacuumPage(gvs.index, buffer);
UnlockReleaseBuffer(buffer);
END_CRIT_SECTION();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment