Re: GIN VACUUM can corrupt internal posting tree pages

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: GIN VACUUM can corrupt internal posting tree pages
Date: 2026-08-19 03:33:53
Message-ID: CAH2-Wzn-dJ_s9Cdbyf-kZX9QbVxbumegswpSzC7OUKR4m5n7Dw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 17, 2026 at 2:15 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> Go ahead and post fixes.

I attach my own fixes for both bugs.

I couldn't resist the temptation to clean up some ginInsertCleanup
related comments in v1-0002-*. I've always found the distinction
between forceCleanup and full_clean confusing. I propose renaming
full_clean to must_empty_list (plus my comment fix ups) to make all
this less confusing.

2016 bug fix commit e2c79e14 seems related to my v1-0002-* patch:

"Previously, ginInsertCleanup could exit early if it detects that
someone else is cleaning up the pending list, without waiting for that
someone else to finish the job. But in this case vacuum could miss
tuples to be deleted."

But it missed that the existing call to ginInsertCleanup still only
happened on the first call to ginbulkdelete, which isn't necessarily
the only one. So I think that it makes sense to think of my v1-0002-*
as fixing an oversight in that 2016 commit. It's certainly a very
similar bug: both bugs involve ginInsertCleanup failing to force TIDs
into the main entry tree, making ginbulkdelete fail to reliably remove
all of the TIDs that VACUUM needs it to remove from the index.

--
Peter Geoghegan

Attachment Content-Type Size
v1-0002-Clean-up-the-GIN-pending-list-on-every-ginbulkdel.patch application/octet-stream 4.1 KB
v1-0001-Re-check-GinPageIsLeaf-after-relocking-a-GIN-post.patch application/octet-stream 1.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nisha Moond 2026-08-19 03:36:37 Re: Support EXCEPT for TABLES IN SCHEMA publications
Previous Message Nisha Moond 2026-08-19 03:26:13 Re: Support EXCEPT for TABLES IN SCHEMA publications