Propagate parallel VACUUM's buffer access strategy.
authorPeter Geoghegan <[email protected]>
Mon, 5 Apr 2021 21:56:56 +0000 (14:56 -0700)
committerPeter Geoghegan <[email protected]>
Mon, 5 Apr 2021 21:56:56 +0000 (14:56 -0700)
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

index cc98ede539484155e138c9276d8c08b0e77fc095..0763ed85d0c146acb70bd06ab2d56f682b8ac7e5 100644 (file)
@@ -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 *));