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

From Peter Geoghegan
Subject pgsql: Fix GIN multiple-VACUUM-scans pending list bug.
Date
Msg-id E1wwkOA-00000001FZc-2gbU@gemulon.postgresql.org
Whole thread
List 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@bowt.ie>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CAH2-Wzmsa-RPA2Ko8A5LaGOnmbpimJ--71xkiBqwgjk3Fq8YEg@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0bace7af3dff862e9643e45df11449857cc56932

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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Defend against null "SV *" pointers in plperl modules.
Next
From: Michael Paquier
Date:
Subject: pgsql: Reject too many arguments in CREATE TRIGGER