git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 679744c)
Fix bug in detecting concurrent page splits in GiST insert
2021年1月20日 09:58:03 +0000 (11:58 +0200)
2021年1月20日 09:58:03 +0000 (11:58 +0200)
In commit 9eb5607e699, I got the condition on checking for split or
deleted page wrong: I used && instead of ||. The comment correctly said
"concurrent split _or_ deletion".

As a result, GiST insertion could miss a concurrent split, and insert to
wrong page. Duncan Sands demonstrated this with a test script that did a
lot of concurrent inserts.

Backpatch to v12, where this was introduced. REINDEX is required to fix
indexes that were affected by this bug.

Backpatch-through: 12
Reported-by: Duncan Sands
Discussion: https://www.postgresql.org/message-id/a9690483-6c6c-3c82-c8ba-dc1a40848f11%40deepbluecap.com


diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 992936cfa8eaca51f4854b8cbe8fe7b04724fffc..f203bb594cdb9ba72c2de83f3fa68de0a3db79c4 100644 (file)
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -248,6 +248,9 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
if (GistFollowRight(page))
elog(ERROR, "concurrent GiST page split was incomplete");
+ /* should never try to insert to a deleted page */
+ Assert(!GistPageIsDeleted(page));
+
*splitinfo = NIL;
/*
@@ -863,7 +866,7 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace,
*/
}
else if ((GistFollowRight(stack->page) ||
- stack->parent->lsn < GistPageGetNSN(stack->page)) &&
+ stack->parent->lsn < GistPageGetNSN(stack->page)) ||
GistPageIsDeleted(stack->page))
{
/*
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /