From 198cc29753b26665af44b4eae3d7c4bdd8b918f3 Mon Sep 17 00:00:00 2001 From: Sami Imseih Date: Fri, 25 Sep 2026 15:06:58 +0000 Subject: [PATCH v1 1/1] Propagate track_cost_delay_timing to parallel autovacuum workers 1ff3180ca01 introduced parallel autovacuum and made sure the cost-based delay parameters were propagated to the workers, but this did not include track_cost_delay_timing, which is an oversight. Workers therefore keep the value they inherited at parallel start, and pg_stat_progress_vacuum.delay_time ends up counting only the leader's naps. Throttling itself was not affected. Fix this by adding the parameter to PVSharedCostParams, and extend the parallel autovacuum test to cover it. --- src/backend/commands/vacuumparallel.c | 11 ++++++++--- .../test_autovacuum/t/001_parallel_autovacuum.pl | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c index 4532da60c84..ec8708c68d0 100644 --- a/src/backend/commands/vacuumparallel.c +++ b/src/backend/commands/vacuumparallel.c @@ -85,6 +85,7 @@ typedef struct PVSharedCostParams int cost_page_dirty; int cost_page_hit; int cost_page_miss; + bool track_delay_timing; } PVSharedCostParams; /* @@ -639,6 +640,7 @@ parallel_vacuum_set_cost_parameters(PVSharedCostParams *params) params->cost_page_dirty = VacuumCostPageDirty; params->cost_page_hit = VacuumCostPageHit; params->cost_page_miss = VacuumCostPageMiss; + params->track_delay_timing = track_cost_delay_timing; } /* @@ -671,6 +673,7 @@ parallel_vacuum_update_shared_delay_params(void) VacuumCostPageDirty = pv_shared_cost_params->cost_page_dirty; VacuumCostPageHit = pv_shared_cost_params->cost_page_hit; VacuumCostPageMiss = pv_shared_cost_params->cost_page_miss; + track_cost_delay_timing = pv_shared_cost_params->track_delay_timing; SpinLockRelease(&pv_shared_cost_params->mutex); VacuumUpdateCosts(); @@ -678,12 +681,13 @@ parallel_vacuum_update_shared_delay_params(void) shared_params_generation_local = params_generation; elog(DEBUG2, - "parallel autovacuum worker updated cost params: cost_limit=%d, cost_delay=%g, cost_page_miss=%d, cost_page_dirty=%d, cost_page_hit=%d", + "parallel autovacuum worker updated cost params: cost_limit=%d, cost_delay=%g, cost_page_miss=%d, cost_page_dirty=%d, cost_page_hit=%d, track_cost_delay_timing=%s", vacuum_cost_limit, vacuum_cost_delay, VacuumCostPageMiss, VacuumCostPageDirty, - VacuumCostPageHit); + VacuumCostPageHit, + track_cost_delay_timing ? "on" : "off"); } /* @@ -710,7 +714,8 @@ parallel_vacuum_propagate_shared_delay_params(void) vacuum_cost_limit == pv_shared_cost_params->cost_limit && VacuumCostPageDirty == pv_shared_cost_params->cost_page_dirty && VacuumCostPageHit == pv_shared_cost_params->cost_page_hit && - VacuumCostPageMiss == pv_shared_cost_params->cost_page_miss) + VacuumCostPageMiss == pv_shared_cost_params->cost_page_miss && + track_cost_delay_timing == pv_shared_cost_params->track_delay_timing) return; /* Update the shared delay parameters */ diff --git a/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl b/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl index 33c86bbdc94..3c54e2cad14 100644 --- a/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl +++ b/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl @@ -149,6 +149,7 @@ $node->safe_psql( ALTER SYSTEM SET vacuum_cost_page_miss = 10; ALTER SYSTEM SET vacuum_cost_page_dirty = 10; ALTER SYSTEM SET vacuum_cost_page_hit = 10; + ALTER SYSTEM SET track_cost_delay_timing = on; SELECT pg_reload_conf(); }); @@ -163,7 +164,7 @@ $node->safe_psql( # Check whether parallel worker successfully updated all parameters during # index processing. $node->wait_for_log( - qr/parallel autovacuum worker updated cost params: cost_limit=500, cost_delay=5, cost_page_miss=10, cost_page_dirty=10, cost_page_hit=10/, + qr/parallel autovacuum worker updated cost params: cost_limit=500, cost_delay=5, cost_page_miss=10, cost_page_dirty=10, cost_page_hit=10, track_cost_delay_timing=on/, $log_offset); # Cleanup -- 2.50.1