Skip to content

Commit 5b861ba

Browse files
nbtree VACUUM: Cope with buggy opclasses.
Teach nbtree VACUUM to press on with vacuuming in the event of a page deletion attempt that fails to "re-find" a downlink for its child/target page. There is no good reason to treat this as an irrecoverable error. But there is a good reason not to: pressing on at this point removes any question of VACUUM not making progress solely due to misbehavior from user-defined operator class code. Discussion: https://postgr.es/m/CAH2-Wzma5G9CTtMjbrXTwOym+U=aWg-R7=-htySuztgoJLvZXg@mail.gmail.com
1 parent 87d90ac commit 5b861ba

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/backend/access/nbtree/nbtpage.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2791,10 +2791,26 @@ _bt_lock_subtree_parent(Relation rel, BlockNumber child, BTStack stack,
27912791
*/
27922792
pbuf = _bt_getstackbuf(rel, stack, child);
27932793
if (pbuf == InvalidBuffer)
2794-
ereport(ERROR,
2794+
{
2795+
/*
2796+
* Failed to "re-find" a pivot tuple whose downlink matched our child
2797+
* block number on the parent level -- the index must be corrupt.
2798+
* Don't even try to delete the leafbuf subtree. Just report the
2799+
* issue and press on with vacuuming the index.
2800+
*
2801+
* Note: _bt_getstackbuf() recovers from concurrent page splits that
2802+
* take place on the parent level. Its approach is a near-exhaustive
2803+
* linear search. This also gives it a surprisingly good chance of
2804+
* recovering in the event of a buggy or inconsistent opclass. But we
2805+
* don't rely on that here.
2806+
*/
2807+
ereport(LOG,
27952808
(errcode(ERRCODE_INDEX_CORRUPTED),
27962809
errmsg_internal("failed to re-find parent key in index \"%s\" for deletion target page %u",
27972810
RelationGetRelationName(rel), child)));
2811+
return false;
2812+
}
2813+
27982814
parent = stack->bts_blkno;
27992815
parentoffset = stack->bts_offset;
28002816

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy