Skip to content

Commit f6b8f19

Browse files
Allocate access strategy in parallel VACUUM workers.
Commit 49f49de 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 40d964e 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.
1 parent 09c1c6a commit f6b8f19

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/backend/access/heap/vacuumlazy.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,6 @@ typedef struct LVShared
194194
Oid relid;
195195
int elevel;
196196

197-
/*
198-
* Buffer access strategy from leader
199-
*/
200-
BufferAccessStrategy bstrategy;
201-
202197
/*
203198
* An indication for vacuum workers to perform either index vacuum or
204199
* index cleanup. first_time is true only if for_cleanup is true and
@@ -3485,7 +3480,6 @@ begin_parallel_vacuum(LVRelState *vacrel, BlockNumber nblocks,
34853480
MemSet(shared, 0, est_shared);
34863481
shared->relid = RelationGetRelid(vacrel->rel);
34873482
shared->elevel = elevel;
3488-
shared->bstrategy = vacrel->bstrategy;
34893483
shared->maintenance_work_mem_worker =
34903484
(nindexes_mwm > 0) ?
34913485
maintenance_work_mem / Min(parallel_workers, nindexes_mwm) :
@@ -3726,7 +3720,8 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc)
37263720
vacrel.rel = rel;
37273721
vacrel.indrels = indrels;
37283722
vacrel.nindexes = nindexes;
3729-
vacrel.bstrategy = lvshared->bstrategy;
3723+
/* Each parallel VACUUM worker gets its own access strategy */
3724+
vacrel.bstrategy = GetAccessStrategy(BAS_VACUUM);
37303725
vacrel.indstats = (IndexBulkDeleteResult **)
37313726
palloc0(nindexes * sizeof(IndexBulkDeleteResult *));
37323727

@@ -3765,6 +3760,7 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc)
37653760

37663761
vac_close_indexes(nindexes, indrels, RowExclusiveLock);
37673762
table_close(rel, ShareUpdateExclusiveLock);
3763+
FreeAccessStrategy(vacrel.bstrategy);
37683764
pfree(vacrel.indstats);
37693765
}
37703766

0 commit comments

Comments
 (0)