Re: [PATCH] Use bounded GIN pending-list cleanup in parallel autovacuum

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Jingtang Zhang <mrdrivingduck(at)gmail(dot)com>
Cc: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Peter Geoghegan <pg(at)bowt(dot)ie>
Subject: Re: [PATCH] Use bounded GIN pending-list cleanup in parallel autovacuum
Date: 2026-09-23 21:19:50
Message-ID: CAD21AoDni8MJ1=oifXKvzr0xo_jk4X71fbNqUWy195Lkk=4GLA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 21, 2026 at 6:34 AM Jingtang Zhang <mrdrivingduck(at)gmail(dot)com> wrote:
>
> Hi Andrey,
>
> Thanks for the review!
>
> > distinguish the leader from its workers. Perhaps a comment at the
> > macro definition noting that autovacuum's parallel workers return
> > false would help prevent similar mistakes.
>
> Attached is v2 with the comment you suggested for
> AmAutoVacuumWorkerProcess().

Thank you for the report and the patch! I think the following comment
should also be updated:

* When running in an autovacuum worker, we won't necessarily _fully_
* empty the pending list. This is still safe; concurrent inserters
* cannot insert new tuples whose TIDs VACUUM needs us to remove.

How about something like this:

* When called by autovacuum, we won't necessarily _fully_ empty the
* pending list. This is still safe; concurrent inserters cannot insert
* new tuples whose TIDs VACUUM needs us to remove.

The reset looks good to me.

>
> > Could we cover the parallel-worker path with a test? One possible
> > scenario is to pause cleanup while flushing the old tail into the main
> > index, append new pending pages, and verify that cleanup leaves those
> > new pages behind. The test would need to ensure that a parallel worker,
> > not the leader, handles the index; otherwise it could pass without
> > the fix. I have not tried this scenario yet.
>
> For the test, I haven't found a reliable way to control the timing
> without adding injection points. We need to ensure that a parallel
> worker handles the index, and append new pending pages while cleanup
> is flushing the old tail into the main index.
>
> Do you have any ideas for a simpler way to test this?

Having a reliable test at a convenient cost seems challenging to me,
and doesn't justify its benefit. I think we can push it without a
test.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2026-09-23 21:21:43 Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Previous Message Zsolt Parragi 2026-09-23 21:19:38 Re: Write skew observed under serializable isolation