postgresql/src
Peter Geoghegan 3f58cc6dd8 Remove extra nbtree half-dead internal page check.
It's not safe for nbtree VACUUM to attempt to delete a target page whose
right sibling is already half-dead, since that would fail the
cross-check when VACUUM attempts to re-find a downlink to the right
sibling in the parent page.  Logic to prevent this from happening was
added by commit 8da3183780, which addressed a bug in the overhaul of
page deletion that went into PostgreSQL 9.4 (commit efada2b8e9).
VACUUM was made to check the right sibling page, and back off when it
happened to be half-dead already.

However, it is only truly necessary to do the right sibling check on the
leaf level, since that transitively determines if the deletion target's
parent's right sibling page is itself undergoing deletion.  Remove the
internal page level check, and add a comment explaining why the leaf
level check alone suffices.

The extra check is also unnecessary due to the fact that internal pages
that are marked half-dead are generally considered corrupt.  Commit
efada2b8e9 established the principle that there should never be
half-dead internal pages (internal pages pending deletion are possible,
but that status is never directly represented in the internal page).
VACUUM will complain about corruption when it encounters half-dead
internal pages, so VACUUM is bound to raise an error one way or another
when an nbtree index has a half-dead internal page (contrib/amcheck will
also report that the page is corrupt).

It's possible that a pg_upgrade'd 9.3 database will still have half-dead
internal pages, so it may seem like there is an argument for leaving the
check in place to reliably get a cleaner error message that advises the
user to REINDEX.  However, leaf pages are also deleted in the first
phase of deletion prior to PostgreSQL 9.4, so I believe we won't even
attempt to re-find the parent page anyway (we won't have the fully
deleted leaf page as the right sibling of our target page, so we won't
even try to find a downlink for it).

Discussion: https://postgr.es/m/CAH2-Wzm_ntmqJjWLRyKzimFmFvk+BnVAvUpaA4s1h9Ja58woaQ@mail.gmail.com
2019-05-16 15:11:58 -07:00
..
backend Remove extra nbtree half-dead internal page check. 2019-05-16 15:11:58 -07:00
bin Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00
common Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00
fe_utils Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00
include Remove no-longer-used typedef. 2019-05-15 17:26:52 -04:00
interfaces Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00
makefiles Define WIN32_STACK_RLIMIT throughout win32 and cygwin builds. 2019-04-09 08:25:39 -07:00
pl Fix grammar in error message 2019-05-09 09:16:59 +02:00
port Assert that pgwin32_signal_initialize() has been called early enough. 2019-04-03 17:11:16 -07:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Fix bogus logic for combining range-partitioned columns during pruning. 2019-05-16 16:25:43 -04:00
timezone Portability fix for zic.c. 2019-04-26 21:20:55 -04:00
tools Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00
tutorial SQL comment: remove extra word in heading comment 2019-01-25 18:57:21 -05:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Consistently test for in-use shared memory. 2019-04-12 22:36:38 -07:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00