1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-02 11:44:50 +03:00

Fix traversing to the deleted GIN page via downlink

Current GIN code appears to don't handle traversing to the deleted page via
downlink.  This commit fixes that by stepping right from the delete page like
we do in nbtree.

This commit also fixes setting 'deleted' flag to the GIN pages.  Now other page
flags are not erased once page is deleted.  That helps to keep our assertions
true if we arrive deleted page via downlink.

Discussion: https://postgr.es/m/CAPpHfdvMvsw-NcE5bRS7R1BbvA4BxoDnVVjkXC5W0Czvy9LVrg%40mail.gmail.com
Author: Alexander Korotkov
Reviewed-by: Peter Geoghegan
Backpatch-through: 9.4
This commit is contained in:
Alexander Korotkov 2019-11-19 23:08:14 +03:00
parent e14641197a
commit d5ad7a09af
4 changed files with 5 additions and 9 deletions

View File

@ -187,13 +187,6 @@ ginStepRight(Buffer buffer, Relation index, int lockmode)
if (isLeaf != GinPageIsLeaf(page) || isData != GinPageIsData(page)) if (isLeaf != GinPageIsLeaf(page) || isData != GinPageIsData(page))
elog(ERROR, "right sibling of GIN page is of different type"); elog(ERROR, "right sibling of GIN page is of different type");
/*
* Given the proper lock sequence above, we should never land on a deleted
* page.
*/
if (GinPageIsDeleted(page))
elog(ERROR, "right sibling of GIN page was deleted");
return nextbuffer; return nextbuffer;
} }

View File

@ -238,6 +238,9 @@ dataIsMoveRight(GinBtree btree, Page page)
if (GinPageRightMost(page)) if (GinPageRightMost(page))
return false; return false;
if (GinPageIsDeleted(page))
return true;
return (ginCompareItemPointers(&btree->itemptr, iptr) > 0) ? true : false; return (ginCompareItemPointers(&btree->itemptr, iptr) > 0) ? true : false;
} }

View File

@ -186,7 +186,7 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn
* we shouldn't change rightlink field to save workability of running * we shouldn't change rightlink field to save workability of running
* search scan * search scan
*/ */
GinPageGetOpaque(page)->flags = GIN_DELETED; GinPageSetDeleted(page);
MarkBufferDirty(pBuffer); MarkBufferDirty(pBuffer);
MarkBufferDirty(lBuffer); MarkBufferDirty(lBuffer);

View File

@ -500,7 +500,7 @@ ginRedoDeletePage(XLogReaderState *record)
{ {
page = BufferGetPage(dbuffer); page = BufferGetPage(dbuffer);
Assert(GinPageIsData(page)); Assert(GinPageIsData(page));
GinPageGetOpaque(page)->flags = GIN_DELETED; GinPageSetDeleted(page);
GinPageSetDeleteXid(page, data->deleteXid); GinPageSetDeleteXid(page, data->deleteXid);
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
MarkBufferDirty(dbuffer); MarkBufferDirty(dbuffer);