summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Korotkov <akorotkov@postgresql.org>2019-11-19 23:08:14 +0300
committerAlexander Korotkov <akorotkov@postgresql.org>2019-11-20 00:05:42 +0300
commitab64b474d9bec8486b42e550526a121f0d81b681 (patch)
treeaf4494d8d6fe470bf5dd61b7f3318f5e64d4b1e3
parent21ad61ab31786128ae780feca8fcf766bbb6a579 (diff)
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
-rw-r--r--src/backend/access/gin/ginbtree.c7
-rw-r--r--src/backend/access/gin/gindatapage.c3
-rw-r--r--src/backend/access/gin/ginvacuum.c2
-rw-r--r--src/backend/access/gin/ginxlog.c2
4 files changed, 5 insertions, 9 deletions
diff --git a/src/backend/access/gin/ginbtree.c b/src/backend/access/gin/ginbtree.c
index b02cb8ae58f..3b241931bbc 100644
--- a/src/backend/access/gin/ginbtree.c
+++ b/src/backend/access/gin/ginbtree.c
@@ -179,13 +179,6 @@ ginStepRight(Buffer buffer, Relation index, int lockmode)
if (isLeaf != GinPageIsLeaf(page) || isData != GinPageIsData(page))
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;
}
diff --git a/src/backend/access/gin/gindatapage.c b/src/backend/access/gin/gindatapage.c
index 62b2f43ac94..dac0c459bed 100644
--- a/src/backend/access/gin/gindatapage.c
+++ b/src/backend/access/gin/gindatapage.c
@@ -237,6 +237,9 @@ dataIsMoveRight(GinBtree btree, Page page)
if (GinPageRightMost(page))
return FALSE;
+ if (GinPageIsDeleted(page))
+ return TRUE;
+
return (ginCompareItemPointers(&btree->itemptr, iptr) > 0) ? TRUE : FALSE;
}
diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c
index ed4ecfd0b13..729e3bac8f2 100644
--- a/src/backend/access/gin/ginvacuum.c
+++ b/src/backend/access/gin/ginvacuum.c
@@ -179,7 +179,7 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn
* we shouldn't change rightlink field to save workability of running
* search scan
*/
- GinPageGetOpaque(page)->flags = GIN_DELETED;
+ GinPageSetDeleted(page);
MarkBufferDirty(pBuffer);
MarkBufferDirty(lBuffer);
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index b86990f3ac7..938ad7d1aad 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -530,7 +530,7 @@ ginRedoDeletePage(XLogReaderState *record)
{
page = BufferGetPage(dbuffer);
Assert(GinPageIsData(page));
- GinPageGetOpaque(page)->flags = GIN_DELETED;
+ GinPageSetDeleted(page);
/*
* deleteXid field of ginxlogDeletePage was added during backpatching.