Skip to content

Commit ab64b47

Browse files
committed
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
1 parent 21ad61a commit ab64b47

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

src/backend/access/gin/ginbtree.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,6 @@ ginStepRight(Buffer buffer, Relation index, int lockmode)
179179
if (isLeaf != GinPageIsLeaf(page) || isData != GinPageIsData(page))
180180
elog(ERROR, "right sibling of GIN page is of different type");
181181

182-
/*
183-
* Given the proper lock sequence above, we should never land on a deleted
184-
* page.
185-
*/
186-
if (GinPageIsDeleted(page))
187-
elog(ERROR, "right sibling of GIN page was deleted");
188-
189182
return nextbuffer;
190183
}
191184

src/backend/access/gin/gindatapage.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ dataIsMoveRight(GinBtree btree, Page page)
237237
if (GinPageRightMost(page))
238238
return FALSE;
239239

240+
if (GinPageIsDeleted(page))
241+
return TRUE;
242+
240243
return (ginCompareItemPointers(&btree->itemptr, iptr) > 0) ? TRUE : FALSE;
241244
}
242245

src/backend/access/gin/ginvacuum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn
179179
* we shouldn't change rightlink field to save workability of running
180180
* search scan
181181
*/
182-
GinPageGetOpaque(page)->flags = GIN_DELETED;
182+
GinPageSetDeleted(page);
183183

184184
MarkBufferDirty(pBuffer);
185185
MarkBufferDirty(lBuffer);

src/backend/access/gin/ginxlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ ginRedoDeletePage(XLogReaderState *record)
530530
{
531531
page = BufferGetPage(dbuffer);
532532
Assert(GinPageIsData(page));
533-
GinPageGetOpaque(page)->flags = GIN_DELETED;
533+
GinPageSetDeleted(page);
534534

535535
/*
536536
* deleteXid field of ginxlogDeletePage was added during backpatching.

0 commit comments

Comments
 (0)