Commit f6b8f19a authored by Peter Geoghegan's avatar Peter Geoghegan

Allocate access strategy in parallel VACUUM workers.

Commit 49f49def took entirely the wrong approach to fixing this issue.
Just allocate a local buffer access strategy in each individual worker
instead of trying to propagate state.  This state was never propagated
by parallel VACUUM in the first place.

It looks like the only reason that this worked following commit 40d964ec
was that it involved static global variables, which are initialized to 0
per the C standard.

A more comprehensive fix may be necessary, even on HEAD.  This fix
should at least get the buildfarm green once again.

Thanks once again to Thomas Munro for continued off-list assistance with
the issue.
parent 09c1c6ab
......@@ -194,11 +194,6 @@ 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
......@@ -3485,7 +3480,6 @@ 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) :
......@@ -3726,7 +3720,8 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc)
vacrel.rel = rel;
vacrel.indrels = indrels;
vacrel.nindexes = nindexes;
vacrel.bstrategy = lvshared->bstrategy;
/* Each parallel VACUUM worker gets its own access strategy */
vacrel.bstrategy = GetAccessStrategy(BAS_VACUUM);
vacrel.indstats = (IndexBulkDeleteResult **)
palloc0(nindexes * sizeof(IndexBulkDeleteResult *));
......@@ -3765,6 +3760,7 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc)
vac_close_indexes(nindexes, indrels, RowExclusiveLock);
table_close(rel, ShareUpdateExclusiveLock);
FreeAccessStrategy(vacrel.bstrategy);
pfree(vacrel.indstats);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment