Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit62a1657

Browse files
committed
Fix corner-case errors in brin_doupdate().
In some cases the BRIN code releases lock on an index page, and laterre-acquires lock and tries to check that the tuple it was working on isstill there. That check was a couple bricks shy of a load. It didn'tconsider that the page might have turned into a "revmap" page. (Thesamepage code path doesn't call brin_getinsertbuffer(), so it isn'tprotected by the checks for revmap status there.) It also didn't checkwhether the tuple offset was now off the end of the linepointer array.Since commit24992c6 the latter case is pretty common, but at leastin principle it could have occurred before that. The net result isthat concurrent updates of a BRIN index could fail with errors like"invalid index offnum" or "inconsistent range map".Per report from Tomas Vondra. Back-patch to 9.5, since this code issubstantially the same in all versions containing BRIN.Discussion:https://postgr.es/m/10d2b9f9-f427-03b8-8ad9-6af4ecacbee9@2ndquadrant.com
1 parent5eb8bf2 commit62a1657

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎src/backend/access/brin/brin_pageops.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,15 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
113113

114114
/*
115115
* Check that the old tuple wasn't updated concurrently: it might have
116-
* moved someplace else entirely ...
116+
* moved someplace else entirely, and for that matter the whole page
117+
* might've become a revmap page. Note that in the first two cases
118+
* checked here, the "oldlp" we just calculated is garbage; but
119+
* PageGetItemId() is simple enough that it was safe to do that
120+
* calculation anyway.
117121
*/
118-
if (!ItemIdIsNormal(oldlp))
122+
if (!BRIN_IS_REGULAR_PAGE(oldpage)||
123+
oldoff>PageGetMaxOffsetNumber(oldpage)||
124+
!ItemIdIsNormal(oldlp))
119125
{
120126
LockBuffer(oldbuf,BUFFER_LOCK_UNLOCK);
121127

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp