diff options
author | Michael Paquier <michael@paquier.xyz> | 2025-09-26 08:41:06 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2025-09-26 08:41:06 +0900 |
commit | 85e0ff62b68224b3354e47fb71b78d309063d06c (patch) | |
tree | 42c39a8a6ca6cee3e50aaed49ae06ea784db6da0 /contrib/pg_overexplain/expected | |
parent | 3760d278dc4165d5eef7435fc62d8ebe13b8e793 (diff) |
Improve stability of btree page split on ERRORsHEADorigin/masterorigin/HEADmaster
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
Diffstat (limited to 'contrib/pg_overexplain/expected')
0 files changed, 0 insertions, 0 deletions