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

Commitae1f9b0

Browse files
committed
Fix amcheck for page checks concurrent to replay of btree page deletion
amcheck expects at least hikey to always exist on leaf page even if it isdeleted page. But replica reinitializes page during replay of page deletion,causing deleted page to have no items. Thus, replay of page deletion cancause an error in concurrent amcheck run.This commit relaxes amcheck expectation making it tolerate deleted page withno items.Reported-by: Konstantin KnizhnikDiscussion:https://postgr.es/m/CAPpHfdt_OTyQpXaPJcWzV2N-LNeNJseNB-K_A66qG%3DL518VTFw%40mail.gmail.comAuthor: Alexander KorotkovReviewed-by: Peter GeogheganBackpatch-through: 11
1 parent891a200 commitae1f9b0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

‎contrib/amcheck/verify_nbtree.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,7 +2416,11 @@ palloc_btree_page(BtreeCheckState *state, BlockNumber blocknum)
24162416
* As noted at the beginning of _bt_binsrch(), an internal page must have
24172417
* children, since there must always be a negative infinity downlink
24182418
* (there may also be a highkey). In the case of non-rightmost leaf
2419-
* pages, there must be at least a highkey.
2419+
* pages, there must be at least a highkey. Deleted pages on replica
2420+
* might contain no items, because page unlink re-initializes
2421+
* page-to-be-deleted. Deleted pages with no items might be on primary
2422+
* too due to preceding recovery, but on primary new deletions can't
2423+
* happen concurrently to amcheck.
24202424
*
24212425
* This is correct when pages are half-dead, since internal pages are
24222426
* never half-dead, and leaf pages must have a high key when half-dead
@@ -2436,13 +2440,13 @@ palloc_btree_page(BtreeCheckState *state, BlockNumber blocknum)
24362440
blocknum,RelationGetRelationName(state->rel),
24372441
MaxIndexTuplesPerPage)));
24382442

2439-
if (!P_ISLEAF(opaque)&&maxoffset<P_FIRSTDATAKEY(opaque))
2443+
if (!P_ISLEAF(opaque)&&!P_ISDELETED(opaque)&&maxoffset<P_FIRSTDATAKEY(opaque))
24402444
ereport(ERROR,
24412445
(errcode(ERRCODE_INDEX_CORRUPTED),
24422446
errmsg("internal block %u in index \"%s\" lacks high key and/or at least one downlink",
24432447
blocknum,RelationGetRelationName(state->rel))));
24442448

2445-
if (P_ISLEAF(opaque)&& !P_RIGHTMOST(opaque)&&maxoffset<P_HIKEY)
2449+
if (P_ISLEAF(opaque)&& !P_ISDELETED(opaque)&& !P_RIGHTMOST(opaque)&&maxoffset<P_HIKEY)
24462450
ereport(ERROR,
24472451
(errcode(ERRCODE_INDEX_CORRUPTED),
24482452
errmsg("non-rightmost leaf block %u in index \"%s\" lacks high key item",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp