8000 nbtree VACUUM: cope with topparent inconsistencies. · postgres/postgres@7ddba19 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ddba19

Browse files
nbtree VACUUM: cope with topparent inconsistencies.
Avoid "right sibling %u of block %u is not next child" errors when vacuuming a corrupt nbtree index. Just LOG the issue and press on. That way VACUUM will have a decent chance of finishing off all required processing for the index (and for the table as a whole). This is similar to recent work from commit 5abff19, as well as work from commit 5b861ba (later backpatched as commit 43e409c), which taught nbtree VACUUM to keep going when its "re-find" check fails. The hardening added by this commit takes place directly after the "re-find" check, right before the critical section for the first stage of page deletion. Author: Peter Geoghegan <pg@bowt.ie> Discussion: https://postgr.es/m/CAH2-Wz=dayg0vjs4+er84TS9ami=csdzjpuiCGbEw=idhwqhzQ@mail.gmail.com Backpatch: 11- (all supported versions).
1 parent 5f5c38b commit 7ddba19

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/backend/access/nbtree/nbtpage.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,9 +1610,19 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack)
16101610
itemid = PageGetItemId(page, nextoffset);
16111611
itup = (IndexTuple) PageGetItem(page, itemid);
16121612
if (BTreeInnerTupleGetDownLink(itup) != rightsib)
1613-
elog(ERROR, "right sibling %u of block %u is not next child %u of block %u in index \"%s\"",
1614-
rightsib, target, BTreeInnerTupleGetDownLink(itup),
1615-
BufferGetBlockNumber(topparent), RelationGetRelationName(rel));
1613+
{
1614+
ereport(LOG,
1615+
(errcode(ERRCODE_INDEX_CORRUPTED),
1616+
errmsg_internal("right sibling %u of block %u is not next child %u of block %u in index \"%s\"",
1617+
rightsib, target,
1618+
BTreeInnerTupleGetDownLink(itup),
1619+
BufferGetBlockNumber(topparent),
1620+
RelationGetRelationName(rel))));
1621+
1622+
_bt_relbuf(rel, topparent);
1623+
1624+
return false;
1625+
}
16161626

16171627
/*
16181628
* Any insert which would have gone on the leaf block will now go to its

0 commit comments

Comments
 (0)
0