aboutsummaryrefslogtreecommitdiff
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:01 +0300
commitee437ca7408b67f2b785e4221c7e567aecf68b47 (patch)
treedb3158ff2f095828060f06cf506dc6ba9f315246
parent051c50c01c32ceb498d53e78f48297713744b7cb (diff)
downloadpostgresql-ee437ca7408b67f2b785e4221c7e567aecf68b47.tar.gz
postgresql-ee437ca7408b67f2b785e4221c7e567aecf68b47.zip
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 11a8ed7bbc2..fde350eef13 100644
--- a/src/backend/access/gin/ginbtree.c
+++ b/src/backend/access/gin/ginbtree.c
@@ -187,13 +187,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 57c3b830d85..197aea3bd30 100644
--- a/src/backend/access/gin/gindatapage.c
+++ b/src/backend/access/gin/gindatapage.c
@@ -238,6 +238,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 85acddc76b3..3a695a05552 100644
--- a/src/backend/access/gin/ginvacuum.c
+++ b/src/backend/access/gin/ginvacuum.c
@@ -186,7 +186,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 c945b282721..387102f21a1 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -500,7 +500,7 @@ ginRedoDeletePage(XLogReaderState *record)
{
page = BufferGetPage(dbuffer);
Assert(GinPageIsData(page));
- GinPageGetOpaque(page)->flags = GIN_DELETED;
+ GinPageSetDeleted(page);
GinPageSetDeleteXid(page, data->deleteXid);
PageSetLSN(page, lsn);
MarkBufferDirty(dbuffer);