Re: POC: Parallel processing of indexes in autovacuum

Daniil Davydov <3danissimo@gmail.com>

From: Daniil Davydov <3danissimo@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Alexander Korotkov <aekorotkov@gmail.com>, SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, Sami Imseih <samimseih@gmail.com>, Matheus Alcantara <matheusssilv97@gmail.com>, Maxim Orlov <orlovmg@gmail.com>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-02T15:10:46Z
Lists: pgsql-hackers

Attachments

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.

--
Best regards,
Daniil Davydov

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Allow autovacuum to use parallel vacuum workers.

  2. Add parallel vacuum worker usage to VACUUM (VERBOSE) and autovacuum logs.

  3. doc: Put new options in consistent order on man pages