Skip to content

Commit 99f5888

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 5bb9954 commit 99f5888

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
@@ -178,13 +178,6 @@ ginStepRight(Buffer buffer, Relation index, int lockmode)
178178
if (isLeaf != GinPageIsLeaf(page) || isData != GinPageIsData(page))
179179
elog(ERROR, "right sibling of GIN page is of different type");
180180

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

src/backend/access/gin/gindatapage.c

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

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

src/backend/access/gin/ginvacuum.c

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

244244
MarkBufferDirty(pBuffer);
245245
MarkBufferDirty(lBuffer);

src/backend/access/gin/ginxlog.c

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

533533
/*
534534
* deleteXid field of ginxlogDeletePage was added during backpatching.

0 commit comments

Comments
 (0)