v21--v22-diff-for-0003.patch
text/x-patch
Filename: v21--v22-diff-for-0003.patch
Type: text/x-patch
Part: 5
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v21-0001
Subject: fixes for 0003 patch
| File | + | − |
|---|---|---|
| src/backend/commands/vacuumparallel.c | 35 | 39 |
| src/tools/pgindent/typedefs.list | 1 | 1 |
From 2e5ab0a4f025900a61a1e34f5d2d163b6ff23f0d Mon Sep 17 00:00:00 2001
From: Daniil Davidov <d.davydov@postgrespro.ru>
Date: Fri, 27 Feb 2026 14:45:22 +0700
Subject: [PATCH 1/3] fixes for 0003 patch
---
src/backend/commands/vacuumparallel.c | 74 +++++++++++++--------------
src/tools/pgindent/typedefs.list | 2 +-
2 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index ccb3812165c..27a6120b0e3 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -57,28 +57,28 @@
* Helper for the PVSharedCostParams structure (see below), to avoid
* repetition.
*/
-typedef struct CostParamsData
+typedef struct VacuumCostParams
{
double cost_delay;
int cost_limit;
int cost_page_dirty;
int cost_page_hit;
int cost_page_miss;
-} CostParamsData;
+} VacuumCostParams;
-#define FillCostParamsData(cost_params) \
+#define FillVacCostParams(cost_params) \
(cost_params)->cost_delay = vacuum_cost_delay; \
(cost_params)->cost_limit = vacuum_cost_limit; \
(cost_params)->cost_page_dirty = VacuumCostPageDirty; \
(cost_params)->cost_page_hit = VacuumCostPageHit; \
(cost_params)->cost_page_miss = VacuumCostPageMiss
-#define CostParamsDataEqual(params_1, params_2) \
- ((params_1).cost_delay == (params_2).cost_delay && \
- (params_1).cost_limit == (params_2).cost_limit && \
- (params_1).cost_page_dirty == (params_2).cost_page_dirty && \
- (params_1).cost_page_hit == (params_2).cost_page_hit && \
- (params_1).cost_page_miss == (params_2).cost_page_miss)
+#define VacCostParamsEquals(params) \
+ (vacuum_cost_delay == (params).cost_delay && \
+ vacuum_cost_limit == (params).cost_limit && \
+ VacuumCostPageDirty == (params).cost_page_dirty && \
+ VacuumCostPageHit == (params).cost_page_hit && \
+ VacuumCostPageMiss == (params).cost_page_miss)
/*
* Struct for cost-based vacuum delay related parameters to share among an
@@ -99,8 +99,11 @@ typedef struct PVSharedCostParams
slock_t mutex; /* protects all fields below */
- /* Copies of corresponding parameters from autovacuum leader process */
- CostParamsData params_data;
+ /*
+ * Copies of the corresponding cost-based vacuum delay parameters from
+ * autovacuum leader process.
+ */
+ VacuumCostParams params_data;
} PVSharedCostParams;
/*
@@ -177,11 +180,11 @@ typedef struct PVShared
* If 'true' then we are running parallel autovacuum. Otherwise, we are
* running parallel maintenence VACUUM.
*/
- bool am_parallel_autovacuum;
+ bool is_autovacuum;
/*
- * Struct for syncing parameters between supportive parallel autovacuum
- * workers with leader worker.
+ * Struct for syncing cost-based vacuum delay parameters between
+ * supportive parallel autovacuum workers with leader worker.
*/
PVSharedCostParams cost_params;
} PVShared;
@@ -462,11 +465,11 @@ parallel_vacuum_init(Relation rel, Relation *indrels, int nindexes,
pg_atomic_init_u32(&(shared->active_nworkers), 0);
pg_atomic_init_u32(&(shared->idx), 0);
- shared->am_parallel_autovacuum = AmAutoVacuumWorkerProcess();
+ shared->is_autovacuum = AmAutoVacuumWorkerProcess();
- if (shared->am_parallel_autovacuum)
+ if (shared->is_autovacuum)
{
- FillCostParamsData(&shared->cost_params.params_data);
+ FillVacCostParams(&shared->cost_params.params_data);
pg_atomic_init_u32(&shared->cost_params.generation, 0);
SpinLockInit(&shared->cost_params.mutex);
@@ -618,10 +621,10 @@ parallel_vacuum_cleanup_all_indexes(ParallelVacuumState *pvs, long num_table_tup
}
/*
- * If we are parallel *autovacuum* worker, check whether related to
- * cost-based delay parameters had changed in the leader worker. If
- * so, corresponding parameters will be updated to the values which
- * leader worker is operating on.
+ * If we are parallel *autovacuum* worker, check whether related to cost-based
+ * vacuum delay parameters had changed in the leader worker. If so,
+ * corresponding parameters will be updated to the values which leader worker
+ * is operating on.
*
* For non-autovacuum parallel worker this function will have no effect.
*/
@@ -629,7 +632,6 @@ void
parallel_vacuum_update_shared_delay_params(void)
{
uint32 params_generation;
- CostParamsData shared_params_data;
Assert(IsParallelWorker());
@@ -646,13 +648,11 @@ parallel_vacuum_update_shared_delay_params(void)
SpinLockAcquire(&pv_shared_cost_params->mutex);
- shared_params_data = pv_shared_cost_params->params_data;
-
- VacuumCostDelay = shared_params_data.cost_delay;
- VacuumCostLimit = shared_params_data.cost_limit;
- VacuumCostPageDirty = shared_params_data.cost_page_dirty;
- VacuumCostPageHit = shared_params_data.cost_page_hit;
- VacuumCostPageMiss = shared_params_data.cost_page_miss;
+ VacuumCostDelay = pv_shared_cost_params->params_data.cost_delay;
+ VacuumCostLimit = pv_shared_cost_params->params_data.cost_limit;
+ VacuumCostPageDirty = pv_shared_cost_params->params_data.cost_page_dirty;
+ VacuumCostPageHit = pv_shared_cost_params->params_data.cost_page_hit;
+ VacuumCostPageMiss = pv_shared_cost_params->params_data.cost_page_miss;
SpinLockRelease(&pv_shared_cost_params->mutex);
@@ -663,34 +663,30 @@ parallel_vacuum_update_shared_delay_params(void)
/*
* Function to be called from parallel autovacuum leader in order to propagate
- * some cost-based parameters to the supportive workers.
+ * some cost-based vacuum delay parameters to the supportive workers.
*/
void
parallel_vacuum_propagate_shared_delay_params(void)
{
- CostParamsData local_params_data;
-
Assert(AmAutoVacuumWorkerProcess());
/* Check whether we are running parallel autovacuum */
if (pv_shared_cost_params == NULL)
return;
- FillCostParamsData(&local_params_data);
SpinLockAcquire(&pv_shared_cost_params->mutex);
- if (CostParamsDataEqual(pv_shared_cost_params->params_data,
- local_params_data))
+ if (VacCostParamsEquals(pv_shared_cost_params->params_data))
{
/*
- * We don't need to update shared delay params if they haven't
- * changed.
+ * We don't need to update shared cost-based vacuum delay params if
+ * they haven't changed.
*/
SpinLockRelease(&pv_shared_cost_params->mutex);
return;
}
- FillCostParamsData(&pv_shared_cost_params->params_data);
+ FillVacCostParams(&pv_shared_cost_params->params_data);
SpinLockRelease(&pv_shared_cost_params->mutex);
/*
@@ -1266,7 +1262,7 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc)
VacuumSharedCostBalance = &(shared->cost_balance);
VacuumActiveNWorkers = &(shared->active_nworkers);
- if (shared->am_parallel_autovacuum)
+ if (shared->is_autovacuum)
pv_shared_cost_params = &(shared->cost_params);
/* Set parallel vacuum state */
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 2d6b57232e6..20fe34f8cc7 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -545,7 +545,6 @@ CopyToRoutine
CopyToState
CopyToStateData
Cost
-CostParamsData
CostSelector
Counters
CoverExt
@@ -3251,6 +3250,7 @@ VacAttrStatsP
VacDeadItemsInfo
VacErrPhase
VacOptValue
+VacuumCostParams
VacuumParams
VacuumRelation
VacuumStmt
--
2.43.0