Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6b4d304

Browse filesBrowse files
committed
Fix bug in detecting concurrent page splits in GiST insert
In commit 9eb5607, 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
1 parent 679744c commit 6b4d304
Copy full SHA for 6b4d304

File tree

Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Open diff view settings
Collapse file

‎src/backend/access/gist/gist.c‎

Copy file name to clipboardExpand all lines: src/backend/access/gist/gist.c
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
248248
if (GistFollowRight(page))
249249
elog(ERROR, "concurrent GiST page split was incomplete");
250250

251+
/* should never try to insert to a deleted page */
252+
Assert(!GistPageIsDeleted(page));
253+
251254
*splitinfo = NIL;
252255

253256
/*
@@ -863,7 +866,7 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace,
863866
*/
864867
}
865868
else if ((GistFollowRight(stack->page) ||
866-
stack->parent->lsn < GistPageGetNSN(stack->page)) &&
869+
stack->parent->lsn < GistPageGetNSN(stack->page)) ||
867870
GistPageIsDeleted(stack->page))
868871
{
869872
/*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.