pgsql: Fix GIN posting tree page deletion with incomplete splits.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix GIN posting tree page deletion with incomplete splits.
Date: 2026-08-22 18:50:54
Message-ID: E1wxqnt-00000001gDl-0R5p@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix GIN posting tree page deletion with incomplete splits.

GIN posting tree page deletion failed to consider whether the target
page's left sibling page, or the deletion target itself, was marked as
incompletely split. Page deletion finds the target page's left sibling
by walking the parent's downlinks, but an incompletely split page's new
right half is part of the sibling chain despite having no downlink.
Deletion could therefore overwrite the rightlink of the wrong page,
disconnecting the split's still-live right half from the sibling chain.
Scans would then silently miss tuples from that page.

To fix, teach the relevant page deletion path to avoid deleting a
posting tree page whose left sibling is marked incompletely split (and
to avoid doing so when the target page itself is so marked). This is
essentially the same approach used by nbtree page deletion.

Claude Code found this problem. The committed test case is a simplified
version of the one that it wrote to demonstrate this bug.

Author: Peter Geoghegan <pg(at)bowt(dot)ie>
Reviewed-by: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Discussion: https://postgr.es/m/CAH2-Wz=sKJcn+OtfVN9rdg+Ps9e4cuQWNP-9t12UE2d8nEG90Q@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9448c3e7ba5c40aadf07e1109685a3691d60880b

Modified Files
--------------
src/backend/access/gin/ginvacuum.c | 19 +++-
src/test/modules/gin/Makefile | 2 +-
.../modules/gin/expected/gin_incomplete_splits.out | 109 ++++++++++++++++++++-
src/test/modules/gin/sql/gin_incomplete_splits.sql | 83 +++++++++++++++-
4 files changed, 208 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-08-23 16:43:09 pgsql: Allow an aggregate's planner support function to be set via CREA
Previous Message Amit Langote 2026-08-22 07:26:06 pgsql: Track RI fast-path FK-check batches per subtransaction