pgsql: nbtree VACUUM: cope with right sibling link corruption. - Mailing list pgsql-committers

From Peter Geoghegan
Subject pgsql: nbtree VACUUM: cope with right sibling link corruption.
Date
Msg-id E1q2JWi-001j9D-Hm@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
nbtree VACUUM: cope with right sibling link corruption.

Avoid "right sibling's left-link doesn't match" 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 error was seen in the field from time to time (it's more than a
theoretical risk), so giving VACUUM the ability to press on like this
has real value.  Nothing short of a REINDEX is expected to fix the
underlying index corruption, so giving up (by throwing an error) risks
making a bad situation far worse.  Anything that blocks forward progress
by VACUUM like this might go unnoticed for a long time.  This could
eventually lead to a wraparound/xidStopLimit outage.

Note that _bt_unlink_halfdead_page() has always been able to bail on
page deletion when the target page's left sibling page was in an
inconsistent state.  It now does the same thing (returns false to back
out of the second phase of deletion) when it notices sibling link
corruption in the target page's right sibling page.

This is similar to the work from commit 5b861baa (later backpatched as
commit 43e409ce), which taught nbtree to press on with vacuuming an
index when page deletion fails to "re-find" a downlink in the target
page's parent page.  The "re-find" check seems to make VACUUM bail on
page deletion more often in practice, but there is no reason to take any
chances here.

Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/CAH2-Wzko2q2kP1+UvgJyP9g0mF4hopK0NtQZcxwvMv9_ytGhkQ@mail.gmail.com
Backpatch: 11- (all supported versions).

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8f876d15ca93f7b62b5daf07ab896573991eb935

Modified Files
--------------
src/backend/access/nbtree/nbtpage.c | 45 ++++++++++++++++++++++++++++---------
src/backend/access/nbtree/nbtree.c  |  3 +--
2 files changed, 35 insertions(+), 13 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix filtering of "cloned" outer-join quals some more.
Next
From: Jeff Davis
Date:
Subject: pgsql: Doc fixes for commit 1e16af8ab5.