pgsql: Fix GIN multiple-VACUUM-scans pending list bug.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix GIN multiple-VACUUM-scans pending list bug.
Date: 2026-08-19 17:47:47
Message-ID: E1wwkOA-00000001FZW-27Ds@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix GIN multiple-VACUUM-scans pending list bug.

ginbulkdelete performs pending list cleanup before it searches the entry
tree (and any posting trees) for dead TIDs. This is necessary to avoid
leaving behind dangling TID references that index vacuuming is required
to remove; nothing prevents recently inserted pending list tuples from
containing TIDs that VACUUM already considers dead.

However, ginbulkdelete neglected to perform pending list cleanup on
VACUUM's second or subsequent call. It was therefore possible for a
VACUUM that requires multiple rounds of index vacuuming to leave behind
dangling references.

To fix, teach ginbulkdelete to perform pending list cleanup during every
call. In passing, tweak some related comments in the pending list
cleanup path to make it clear why it's safe for VACUUM to not _fully_
empty an index's pending list.

This was arguably an oversight in commit e2c79e14, which fixed a similar
issue where pending list cleanup by VACUUM could end early, but missed
this closely related problem.

Author: Peter Geoghegan <pg(at)bowt(dot)ie>
Reviewed-by: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Discussion: https://postgr.es/m/CAH2-Wzmsa-RPA2Ko8A5LaGOnmbpimJ--71xkiBqwgjk3Fq8YEg@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d778f00c145d94285e77587f00a44dcf99cc0620

Modified Files
--------------
src/backend/access/gin/ginfast.c | 15 +++++++++------
src/backend/access/gin/ginvacuum.c | 18 ++++++++++++------
src/include/access/gin_private.h | 2 +-
3 files changed, 22 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-08-19 18:07:05 pgsql: Support tied Perl objects in plperl and associated contrib modul
Previous Message Peter Geoghegan 2026-08-19 16:31:24 pgsql: Fix GIN VACUUM posting tree root split bug.