diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2019-11-19 23:08:14 +0300 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2019-11-19 23:47:29 +0300 |
commit | 99f5888d358a5db375ce0299b18fb47ccfa1646c (patch) | |
tree | 6e8c71b9c3e7223780cc258d957129151caf717f /src/backend | |
parent | 5bb9954c1cda315add1ceeeec601eadf6ee48c0c (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
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/gin/ginbtree.c | 7 | ||||
-rw-r--r-- | src/backend/access/gin/gindatapage.c | 3 | ||||
-rw-r--r-- | src/backend/access/gin/ginvacuum.c | 2 | ||||
-rw-r--r-- | src/backend/access/gin/ginxlog.c | 2 |
4 files changed, 5 insertions, 9 deletions
diff --git a/src/backend/access/gin/ginbtree.c b/src/backend/access/gin/ginbtree.c index a0afec4f3c0..f5c41bac5c5 100644 --- a/src/backend/access/gin/ginbtree.c +++ b/src/backend/access/gin/ginbtree.c @@ -178,13 +178,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 cd3b9dfb784..87cbd08189c 100644 --- a/src/backend/access/gin/gindatapage.c +++ b/src/backend/access/gin/gindatapage.c @@ -236,6 +236,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 58f0d03fd1e..0722a0cbbac 100644 --- a/src/backend/access/gin/ginvacuum.c +++ b/src/backend/access/gin/ginvacuum.c @@ -239,7 +239,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 3b503d52caa..2356a1643d5 100644 --- a/src/backend/access/gin/ginxlog.c +++ b/src/backend/access/gin/ginxlog.c @@ -528,7 +528,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. |