From 49f49defe7c0a330cca084de5da14ccdfdafc6a3 Mon Sep 17 00:00:00 2001 From: Peter Geoghegan Date: Mon, 5 Apr 2021 14:56:56 -0700 Subject: [PATCH] Propagate parallel VACUUM's buffer access strategy. Parallel VACUUM relied on global variable state from the leader process being propagated to workers on fork(). Commit b4af70cb removed most uses of global variables inside vacuumlazy.c, but did not account for the buffer access strategy state. To fix, propagate the state through shared memory instead. Per buildfarm failures on elver, curculio, and morepork. Many thanks to Thomas Munro for off-list assistance with this issue. --- src/backend/access/heap/vacuumlazy.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index cc98ede539..0763ed85d0 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -194,6 +194,11 @@ typedef struct LVShared Oid relid; int elevel; + /* + * Buffer access strategy from leader + */ + BufferAccessStrategy bstrategy; + /* * An indication for vacuum workers to perform either index vacuum or * index cleanup. first_time is true only if for_cleanup is true and @@ -3480,6 +3485,7 @@ begin_parallel_vacuum(LVRelState *vacrel, BlockNumber nblocks, MemSet(shared, 0, est_shared); shared->relid = RelationGetRelid(vacrel->rel); shared->elevel = elevel; + shared->bstrategy = vacrel->bstrategy; shared->maintenance_work_mem_worker = (nindexes_mwm > 0) ? maintenance_work_mem / Min(parallel_workers, nindexes_mwm) : @@ -3720,6 +3726,7 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc) vacrel.rel = rel; vacrel.indrels = indrels; vacrel.nindexes = nindexes; + vacrel.bstrategy = lvshared->bstrategy; vacrel.indstats = (IndexBulkDeleteResult **) palloc0(nindexes * sizeof(IndexBulkDeleteResult *));