Re: POC: Parallel processing of indexes in autovacuum - Mailing list pgsql-hackers

From Masahiko Sawada
Subject Re: POC: Parallel processing of indexes in autovacuum
Date
Msg-id CAD21AoA_eRa9nVCenw3tnVwUCgR-Jk4=W4GuV36+oYKgBmRwNA@mail.gmail.com
Whole thread
In response to Re: POC: Parallel processing of indexes in autovacuum  (Daniil Davydov <3danissimo@gmail.com>)
Responses Re: POC: Parallel processing of indexes in autovacuum
List pgsql-hackers
On Thu, Apr 2, 2026 at 8:10 AM Daniil Davydov <3danissimo@gmail.com> wrote:
>
> Hi,
>
> On Thu, Apr 2, 2026 at 6:16 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> >
> > Thank you for updating the patch! I found a bug in the following code:
> >
> > @@ -457,6 +534,9 @@ parallel_vacuum_end(ParallelVacuumState *pvs,
> > IndexBulkDeleteResult **istats)
> >   DestroyParallelContext(pvs->pcxt);
> >   ExitParallelMode();
> >
> > + if (AmAutoVacuumWorkerProcess())
> > + pv_shared_cost_params = NULL;
> > +
> >
> > If an autovacuum worker raises an error during parallel vacuum, it
> > doesn't pv_shared_cost_params. Then, if it doesn't use parallel vacuum
> > on the next table to vacuum, it would end up with SEGV as it attempts
> > to propagate the vacuum delay parameters.
>
> Ouch. Indeed, I did not foresee this.
> Thank you for noticing it!
>
> I think we should add some cleanup for autovacuum near the ParallelContext
> cleanup, since they are interconnected. I also want to return our tests that
> are triggering ERROR/PANIC in the leader worker in order to check whether all
> resources are released. I hope I will be able to get to that by tomorrow
> evening.

I think that the beginning of vacuum loop (in PG_TRY() block in
vacuum()) seems better place as we're resetting vacuum delay
parameters:

        in_vacuum = true;
        VacuumFailsafeActive = false;
        VacuumUpdateCosts();
        VacuumCostBalance = 0;
        VacuumCostBalanceLocal = 0;
        VacuumSharedCostBalance = NULL;
        VacuumActiveNWorkers = NULL;

Regards,

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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_waldump: support decoding of WAL inside tarfile
Next
From: Lukas Fittl
Date:
Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?