pgsql: Don't fully empty GIN pending list in parallel autovacuum worker

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't fully empty GIN pending list in parallel autovacuum worker
Date: 2026-09-24 17:33:09
Message-ID: E1x9nJl-0000000160l-0SHp@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't fully empty GIN pending list in parallel autovacuum workers.

Autovacuum doesn't necessarily fully empty the GIN pending list. It
stops at the tail as of the start of cleanup, so that it doesn't keep
chasing pages appended by concurrent inserters. GIN decided this with
AmAutoVacuumWorkerProcess(), which returns false in parallel vacuum
workers launched by an autovacuum worker, so those workers tried to
fully empty the list as a manual VACUUM does.

Fix this by adding an is_autovacuum field to IndexVacuumInfo, set from
the shared parallel vacuum state in parallel workers, and using it in
GIN instead of checking the process type.

Oversight in commit 1ff3180ca01.

Reported-by: Jingtang Zhang <mrdrivingduck(at)gmail(dot)com>
Author: Jingtang Zhang <mrdrivingduck(at)gmail(dot)com>
Reviewed-by: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Reviewed-by: Yuhang Qiu <iamqyh(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAPsk3_DiF2i1o=JRXRk1YPVMv1VzJaCAbfiEqgwCva4=ZewVAw@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8be38b238a61d58b6c0f21d4c1d8e9c1d26d8b58

Modified Files
--------------
src/backend/access/gin/ginvacuum.c | 12 ++++++------
src/backend/access/heap/vacuumlazy.c | 2 ++
src/backend/catalog/index.c | 1 +
src/backend/commands/analyze.c | 1 +
src/backend/commands/vacuumparallel.c | 1 +
src/include/access/genam.h | 1 +
src/include/miscadmin.h | 1 +
7 files changed, 13 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-09-24 17:33:12 pgsql: Don't fully empty GIN pending list in parallel autovacuum worker
Previous Message Tom Lane 2026-09-24 17:28:21 pgsql: Suppress -Wshadow=local warnings in REG_DEBUG code.