]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Allocate access strategy in parallel VACUUM workers.
authorAmit Kapila <akapila@postgresql.org>
Mon, 12 Apr 2021 03:33:16 +0000 (09:03 +0530)
committerAmit Kapila <akapila@postgresql.org>
Mon, 12 Apr 2021 03:33:16 +0000 (09:03 +0530)
Currently, parallel vacuum workers don't use any buffer access strategy.
We can fix it either by propagating the access strategy from a leader or
allow each worker to use BAS_VACUUM access strategy type. We don't see
much use in propagating this information from leader as both leader and
workers are supposed to use the same strategy. We might want to use a
different access strategy for leader and workers but that would be a
separate optimization not suitable for back-branches. This has been fixed
in HEAD as commit f6b8f19a08.

Author: Amit Kapila
Reviewed-by: Sawada Masahiko, Bharath Rupireddy
Discussion: https://postgr.es/m/CAA4eK1KbmJgRV2W3BbzRnKUSrukN7SbqBBriC4RDB5KBhopkGQ@mail.gmail.com

src/backend/access/heap/vacuumlazy.c

index d6a8cf390c2e437d8076567b6b43a18cf67b95ae..fe2a6062b9c45c59f7be45264b248360a8bff3ce 100644 (file)
@@ -3510,6 +3510,9 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc)
        vac_open_indexes(onerel, RowExclusiveLock, &nindexes, &indrels);
        Assert(nindexes > 0);
 
+       /* Each parallel VACUUM worker gets its own access strategy */
+       vac_strategy = GetAccessStrategy(BAS_VACUUM);
+
        /* Set dead tuple space */
        dead_tuples = (LVDeadTuples *) shm_toc_lookup(toc,
                                                                                                  PARALLEL_VACUUM_KEY_DEAD_TUPLES,
@@ -3564,6 +3567,7 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc)
 
        vac_close_indexes(nindexes, indrels, RowExclusiveLock);
        table_close(onerel, ShareUpdateExclusiveLock);
+       FreeAccessStrategy(vac_strategy);
        pfree(stats);
 }