v28--v29-diff-for-0001.patch
text/x-patch
Filename: v28--v29-diff-for-0001.patch
Type: text/x-patch
Part: 7
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 v28-0002
Subject: fixup for logging.
| File | + | − |
|---|---|---|
| src/backend/access/heap/vacuumlazy.c | 17 | 18 |
| src/backend/commands/vacuumparallel.c | 9 | 12 |
| src/include/commands/vacuum.h | 13 | 13 |
| src/tools/pgindent/typedefs.list | 2 | 2 |
From 1571b7a2eb7dacbd80c697aab937e398c0f70daf Mon Sep 17 00:00:00 2001
From: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Mon, 16 Mar 2026 15:09:26 -0700
Subject: [PATCH 2/9] fixup for logging.
---
src/backend/access/heap/vacuumlazy.c | 35 +++++++++++++--------------
src/backend/commands/vacuumparallel.c | 21 +++++++---------
src/include/commands/vacuum.h | 26 ++++++++++----------
src/tools/pgindent/typedefs.list | 4 +--
4 files changed, 41 insertions(+), 45 deletions(-)
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index cccaee5b620..c57432670e7 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -346,9 +346,9 @@ typedef struct LVRelState
/*
* Total number of planned and actually launched parallel workers for
- * index scans.
+ * index vacuuming and index cleanup.
*/
- PVWorkersUsage workers_usage;
+ PVWorkerUsage worker_usage;
/* Counters that follow are only for scanned_pages */
int64 tuples_deleted; /* # deleted from table */
@@ -788,10 +788,10 @@ heap_vacuum_rel(Relation rel, const VacuumParams params,
vacrel->new_all_visible_all_frozen_pages = 0;
vacrel->new_all_frozen_pages = 0;
- vacrel->workers_usage.vacuum.nlaunched = 0;
- vacrel->workers_usage.vacuum.nplanned = 0;
- vacrel->workers_usage.cleanup.nlaunched = 0;
- vacrel->workers_usage.cleanup.nplanned = 0;
+ vacrel->worker_usage.vacuum.nlaunched = 0;
+ vacrel->worker_usage.vacuum.nplanned = 0;
+ vacrel->worker_usage.cleanup.nlaunched = 0;
+ vacrel->worker_usage.cleanup.nplanned = 0;
/*
* Get cutoffs that determine which deleted tuples are considered DEAD,
@@ -1135,20 +1135,19 @@ heap_vacuum_rel(Relation rel, const VacuumParams params,
orig_rel_pages == 0 ? 100.0 :
100.0 * vacrel->lpdead_item_pages / orig_rel_pages,
vacrel->lpdead_items);
- if (vacrel->workers_usage.vacuum.nplanned > 0)
- {
+
+ if (vacrel->worker_usage.vacuum.nplanned > 0)
appendStringInfo(&buf,
_("parallel workers: index vacuum: %d planned, %d launched in total\n"),
- vacrel->workers_usage.vacuum.nplanned,
- vacrel->workers_usage.vacuum.nlaunched);
- }
- if (vacrel->workers_usage.cleanup.nplanned > 0)
- {
+ vacrel->worker_usage.vacuum.nplanned,
+ vacrel->worker_usage.vacuum.nlaunched);
+
+ if (vacrel->worker_usage.cleanup.nplanned > 0)
appendStringInfo(&buf,
_("parallel workers: index cleanup: %d planned, %d launched\n"),
- vacrel->workers_usage.cleanup.nplanned,
- vacrel->workers_usage.cleanup.nlaunched);
- }
+ vacrel->worker_usage.cleanup.nplanned,
+ vacrel->worker_usage.cleanup.nlaunched);
+
for (int i = 0; i < vacrel->nindexes; i++)
{
IndexBulkDeleteResult *istat = vacrel->indstats[i];
@@ -2696,7 +2695,7 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
/* Outsource everything to parallel variant */
parallel_vacuum_bulkdel_all_indexes(vacrel->pvs, old_live_tuples,
vacrel->num_index_scans,
- &vacrel->workers_usage);
+ &(vacrel->worker_usage.vacuum));
/*
* Do a postcheck to consider applying wraparound failsafe now. Note
@@ -3131,7 +3130,7 @@ lazy_cleanup_all_indexes(LVRelState *vacrel)
parallel_vacuum_cleanup_all_indexes(vacrel->pvs, reltuples,
vacrel->num_index_scans,
estimated_count,
- &vacrel->workers_usage);
+ &(vacrel->worker_usage.cleanup));
}
/* Reset the progress counters */
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index 692729efd5e..77834b96a21 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -225,7 +225,7 @@ struct ParallelVacuumState
static int parallel_vacuum_compute_workers(Relation *indrels, int nindexes, int nrequested,
bool *will_parallel_vacuum);
static void parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scans,
- bool vacuum, PVWorkersStats *wstats);
+ bool vacuum, PVWorkerStats *wstats);
static void parallel_vacuum_process_safe_indexes(ParallelVacuumState *pvs);
static void parallel_vacuum_process_unsafe_indexes(ParallelVacuumState *pvs);
static void parallel_vacuum_process_one_index(ParallelVacuumState *pvs, Relation indrel,
@@ -499,7 +499,7 @@ parallel_vacuum_reset_dead_items(ParallelVacuumState *pvs)
*/
void
parallel_vacuum_bulkdel_all_indexes(ParallelVacuumState *pvs, long num_table_tuples,
- int num_index_scans, PVWorkersUsage *wusage)
+ int num_index_scans, PVWorkerStats *wstats)
{
Assert(!IsParallelWorker());
@@ -510,8 +510,7 @@ parallel_vacuum_bulkdel_all_indexes(ParallelVacuumState *pvs, long num_table_tup
pvs->shared->reltuples = num_table_tuples;
pvs->shared->estimated_count = true;
- parallel_vacuum_process_all_indexes(pvs, num_index_scans, true,
- &wusage->vacuum);
+ parallel_vacuum_process_all_indexes(pvs, num_index_scans, true, wstats);
}
/*
@@ -520,7 +519,7 @@ parallel_vacuum_bulkdel_all_indexes(ParallelVacuumState *pvs, long num_table_tup
void
parallel_vacuum_cleanup_all_indexes(ParallelVacuumState *pvs, long num_table_tuples,
int num_index_scans, bool estimated_count,
- PVWorkersUsage *wusage)
+ PVWorkerStats *wstats)
{
Assert(!IsParallelWorker());
@@ -532,8 +531,7 @@ parallel_vacuum_cleanup_all_indexes(ParallelVacuumState *pvs, long num_table_tup
pvs->shared->reltuples = num_table_tuples;
pvs->shared->estimated_count = estimated_count;
- parallel_vacuum_process_all_indexes(pvs, num_index_scans, false,
- &wusage->cleanup);
+ parallel_vacuum_process_all_indexes(pvs, num_index_scans, false, wstats);
}
/*
@@ -611,12 +609,11 @@ parallel_vacuum_compute_workers(Relation *indrels, int nindexes, int nrequested,
* Perform index vacuum or index cleanup with parallel workers. This function
* must be used by the parallel vacuum leader process.
*
- * If wstats is not NULL, the statistics it stores will be updated according
- * to what happens during function execution.
+ * If wstats is not NULL, the parallel worker statistics are updated.
*/
static void
parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scans,
- bool vacuum, PVWorkersStats *wstats)
+ bool vacuum, PVWorkerStats *wstats)
{
int nworkers;
PVIndVacStatus new_status;
@@ -653,7 +650,7 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
*/
nworkers = Min(nworkers, pvs->pcxt->nworkers);
- /* Remember this value, if we asked to */
+ /* Update the statistics, if we asked to */
if (wstats != NULL && nworkers > 0)
wstats->nplanned += nworkers;
@@ -714,7 +711,7 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
VacuumSharedCostBalance = &(pvs->shared->cost_balance);
VacuumActiveNWorkers = &(pvs->shared->active_nworkers);
- /* Remember this value, if we asked to */
+ /* Update the statistics, if we asked to */
if (wstats != NULL)
wstats->nlaunched += pvs->pcxt->nworkers_launched;
}
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index 1d820915d71..953a506181e 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -301,26 +301,26 @@ typedef struct VacDeadItemsInfo
} VacDeadItemsInfo;
/*
- * Helper for the PVWorkersUsage structure (see below), to avoid repetition.
+ * Statistics for parallel vacuum workers (planned vs. actual)
*/
-typedef struct PVWorkersStats
+typedef struct PVWorkerStats
{
- /* Number of parallel workers we are planned to launch */
+ /* Number of parallel workers planned to launch */
int nplanned;
- /* Number of launched parallel workers */
+ /* Number of parallel workers that were successfully launched */
int nlaunched;
-} PVWorkersStats;
+} PVWorkerStats;
/*
- * PVWorkersUsage stores information about total number of launched and
- * planned workers during parallel vacuum (both for vacuum and cleanup).
+ * PVWorkerUsage stores information about total number of launched and
+ * planned workers during parallel vacuum (both for index vacuum and cleanup).
*/
-typedef struct PVWorkersUsage
+typedef struct PVWorkerUsage
{
- PVWorkersStats vacuum;
- PVWorkersStats cleanup;
-} PVWorkersUsage;
+ PVWorkerStats vacuum;
+ PVWorkerStats cleanup;
+} PVWorkerUsage;
/* GUC parameters */
extern PGDLLIMPORT int default_statistics_target; /* PGDLLIMPORT for PostGIS */
@@ -417,12 +417,12 @@ extern void parallel_vacuum_reset_dead_items(ParallelVacuumState *pvs);
extern void parallel_vacuum_bulkdel_all_indexes(ParallelVacuumState *pvs,
long num_table_tuples,
int num_index_scans,
- PVWorkersUsage *wusage);
+ PVWorkerStats *wstats);
extern void parallel_vacuum_cleanup_all_indexes(ParallelVacuumState *pvs,
long num_table_tuples,
int num_index_scans,
bool estimated_count,
- PVWorkersUsage *wusage);
+ PVWorkerStats *wstats);
extern void parallel_vacuum_main(dsm_segment *seg, shm_toc *toc);
/* in commands/analyze.c */
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index a67d54e1819..4c230ee38ca 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -2088,8 +2088,8 @@ PVIndStats
PVIndVacStatus
PVOID
PVShared
-PVWorkersUsage
-PVWorkersStats
+PVWorkerUsage
+PVWorkerStats
PX_Alias
PX_Cipher
PX_Combo
--
2.43.0