postgres/src
Michael Paquier 85e0ff62b6 Improve stability of btree page split on ERRORs
This improves the stability of VACUUM when processing btree indexes,
which was previously able to trigger an assertion failure in
_bt_lock_subtree_parent() when an error was previously thrown outside
the scope of _bt_split() when splitting a btree page.  VACUUM would
consider the index as in a corrupted state as the right page would not
be zeroed for the error thrown (allocation failure is one pattern).

In a non-assert build, VACUUM is able to succeed, reporting what it sees
as a corruption while attempting to fix the index.  This would manifest
as a LOG message, as of:
LOG: failed to re-find parent key in index "idx" for deletion target
page N
CONTEXT:  while vacuuming index "idx" of relation "public.tab"

This commit improves the code to rely on two PGAlignedBlocks that are
used as a temporary space for the left and right pages.  The main change
concerns the right page, whose contents are now copied into the
"temporary" PGAlignedBlock page while its original space is zeroed.  Its
contents are moved from the PGAlignedBlock page back to the page once we
enter in the critical section used for the split.  This simplifies the
split logic, as it is not necessary to zero the right page before
throwing an error anymore.  Hence errors can now be thrown outside the
split code.  For the left page, this shaves one allocation, with
PageGetTempPage() being previously used.

The previous logic originates from commit 8fa30f906b, at a point where
PGAlignedBlock did not exist yet.  This could be argued as something
that should be backpatched, but the lack of complaints indicates that it
may not be necessary.

Author: Konstantin Knizhnik <knizhnik@garret.ru>
Discussion: https://postgr.es/m/566dacaf-5751-47e4-abc6-73de17a5d42a@garret.ru
2025-09-26 08:41:06 +09:00
..
backend Improve stability of btree page split on ERRORs 2025-09-26 08:41:06 +09:00
bin psql: Add COMPLETE_WITH_FILES and COMPLETE_WITH_GENERATOR macros. 2025-09-25 14:28:01 -07:00
common Don't put library-supplied -L/-I switches before user-supplied ones. 2025-07-29 15:17:40 -04:00
fe_utils meson: add and use stamp files for generated headers 2025-08-11 15:18:23 -04:00
include Don't include execnodes.h in replication/conflict.h 2025-09-25 14:52:41 +02:00
interfaces Move pg_int64 back to postgres_ext.h 2025-09-16 10:48:56 +02:00
makefiles Remove traces of support for Sun Studio compiler 2025-09-12 07:39:05 +02:00
pl Provide more-specific error details/hints for function lookup failures. 2025-09-16 12:17:02 -04:00
port Use strchr instead of strstr for single-char lookups 2025-07-23 12:02:55 +12:00
template Remove traces of support for Sun Studio compiler 2025-09-12 07:39:05 +02:00
test Add minimal sleep to stats isolation test functions. 2025-09-25 13:29:37 -04:00
timezone Generate GUC tables from .dat file 2025-09-03 09:45:17 +02:00
tools Keep track of what RTIs a Result node is scanning. 2025-09-23 09:07:55 -04:00
tutorial
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Remove traces of support for Sun Studio compiler 2025-09-12 07:39:05 +02:00
Makefile.shlib Use exported symbols list on macOS for loadable modules as well 2025-06-10 07:04:43 +02:00
meson.build
nls-global.mk