v20--v21-diff-for-0002.patch
text/x-patch
Filename: v20--v21-diff-for-0002.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 v20-0003
Subject: fixes for patch 2
| File | + | − |
|---|---|---|
| src/backend/access/heap/vacuumlazy.c | 44 | 16 |
| src/backend/commands/vacuumparallel.c | 12 | 10 |
| src/include/commands/vacuum.h | 12 | 3 |
| src/tools/pgindent/typedefs.list | 2 | 0 |
From b7a0226646ee306400ca50c5404f3f02b0c7fda0 Mon Sep 17 00:00:00 2001
From: Daniil Davidov <d.davydov@postgrespro.ru>
Date: Sat, 7 Feb 2026 00:11:49 +0700
Subject: [PATCH 3/7] fixes for patch 2
---
src/backend/access/heap/vacuumlazy.c | 60 ++++++++++++++++++++-------
src/backend/commands/vacuumparallel.c | 22 +++++-----
src/include/commands/vacuum.h | 15 +++++--
src/tools/pgindent/typedefs.list | 2 +
4 files changed, 70 insertions(+), 29 deletions(-)
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index d14f055b40d..d19e15cbcce 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -784,8 +784,10 @@ heap_vacuum_rel(Relation rel, const VacuumParams params,
vacrel->vm_new_visible_frozen_pages = 0;
vacrel->vm_new_frozen_pages = 0;
- vacrel->workers_usage.nlaunched = 0;
- vacrel->workers_usage.nplanned = 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;
/*
* Get cutoffs that determine which deleted tuples are considered DEAD,
@@ -1129,23 +1131,49 @@ 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.nplanned > 0 &&
- AmAutoVacuumWorkerProcess())
+ if (vacrel->workers_usage.vacuum.nplanned > 0)
{
- /* Worker usage stats for parallel autovacuum */
- appendStringInfo(&buf,
- _("parallel index vacuum/cleanup: %d workers were planned, %d workers were reserved and %d workers were launched in total\n"),
- vacrel->workers_usage.nplanned,
- vacrel->workers_usage.nreserved,
- vacrel->workers_usage.nlaunched);
+ /* Stats for vacuum phase of index vacuuming. */
+
+ if (AmAutoVacuumWorkerProcess())
+ {
+ /* Worker usage stats for parallel autovacuum. */
+ appendStringInfo(&buf,
+ _("parallel index vacuum: %d workers were planned, %d workers were reserved and %d workers were launched in total\n"),
+ vacrel->workers_usage.vacuum.nplanned,
+ vacrel->workers_usage.vacuum.nreserved,
+ vacrel->workers_usage.vacuum.nlaunched);
+ }
+ else
+ {
+ /* Worker usage stats for manual VACUUM (PARALLEL). */
+ appendStringInfo(&buf,
+ _("parallel index vacuum: %d workers were planned and %d workers were launched in total\n"),
+ vacrel->workers_usage.vacuum.nplanned,
+ vacrel->workers_usage.vacuum.nlaunched);
+ }
}
- else if (vacrel->workers_usage.nplanned > 0)
+ if (vacrel->workers_usage.cleanup.nplanned > 0)
{
- /* Worker usage stats for manual VACUUM (PARALLEL) */
- appendStringInfo(&buf,
- _("parallel index vacuum/cleanup: %d workers were planned and %d workers were launched in total\n"),
- vacrel->workers_usage.nplanned,
- vacrel->workers_usage.nlaunched);
+ /* Stats for cleanup phase of index vacuuming. */
+
+ if (AmAutoVacuumWorkerProcess())
+ {
+ /* Worker usage stats for parallel autovacuum. */
+ appendStringInfo(&buf,
+ _("parallel index cleanup: %d workers were planned, %d workers were reserved and %d workers were launched in total\n"),
+ vacrel->workers_usage.cleanup.nplanned,
+ vacrel->workers_usage.cleanup.nreserved,
+ vacrel->workers_usage.cleanup.nlaunched);
+ }
+ else
+ {
+ /* Worker usage stats for manual VACUUM (PARALLEL). */
+ appendStringInfo(&buf,
+ _("parallel index cleanup: %d workers were planned and %d workers were launched in total\n"),
+ vacrel->workers_usage.cleanup.nplanned,
+ vacrel->workers_usage.cleanup.nlaunched);
+ }
}
for (int i = 0; i < vacrel->nindexes; i++)
{
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index ea45dc3fc37..86d9f2b74c9 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -227,7 +227,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, PVWorkersUsage *wusage);
+ bool vacuum, PVWorkersStats *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,
@@ -513,7 +513,8 @@ 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);
+ parallel_vacuum_process_all_indexes(pvs, num_index_scans, true,
+ &wusage->vacuum);
}
/*
@@ -534,7 +535,8 @@ 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);
+ parallel_vacuum_process_all_indexes(pvs, num_index_scans, false,
+ &wusage->cleanup);
}
/*
@@ -619,7 +621,7 @@ parallel_vacuum_compute_workers(Relation *indrels, int nindexes, int nrequested,
*/
static void
parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scans,
- bool vacuum, PVWorkersUsage *wusage)
+ bool vacuum, PVWorkersStats *wstats)
{
int nworkers;
PVIndVacStatus new_status;
@@ -657,8 +659,8 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
nworkers = Min(nworkers, pvs->pcxt->nworkers);
/* Remember this value, if we asked to */
- if (wusage != NULL && nworkers > 0)
- wusage->nplanned += nworkers;
+ if (wstats != NULL && nworkers > 0)
+ wstats->nplanned += nworkers;
/*
* Reserve workers in autovacuum global state. Note that we may be given
@@ -669,8 +671,8 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
AutoVacuumReserveParallelWorkers(&nworkers);
/* Remember this value, if we asked to */
- if (wusage != NULL)
- wusage->nreserved += nworkers;
+ if (wstats != NULL)
+ wstats->nreserved += nworkers;
}
/*
@@ -741,8 +743,8 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
VacuumActiveNWorkers = &(pvs->shared->active_nworkers);
/* Remember this value, if we asked to */
- if (wusage != NULL)
- wusage->nlaunched += pvs->pcxt->nworkers_launched;
+ if (wstats != NULL)
+ wstats->nlaunched += pvs->pcxt->nworkers_launched;
}
if (vacuum)
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index 7cbb59d124f..d3dc4e8cc67 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -301,16 +301,25 @@ typedef struct VacDeadItemsInfo
} VacDeadItemsInfo;
/*
- * PVWorkersUsage stores information about total number of launched, reserved
- * and planned workers during parallel vacuum.
+ * Helper for the PVWorkersUsage structure (see below), to avoid repetition.
*/
-typedef struct PVWorkersUsage
+typedef struct PVWorkersStats
{
int nplanned; /* # of parallel workers we are planned to
* launch */
int nreserved; /* for autovacuum only - # of parallel workers
* we have managed to reserve */
int nlaunched; /* # of launched parallel workers */
+} PVWorkersStats;
+
+/*
+ * PVWorkersUsage stores information about total number of launched, reserved
+ * and planned workers during parallel vacuum (both for vacuum and cleanup).
+ */
+typedef struct PVWorkersUsage
+{
+ PVWorkersStats vacuum;
+ PVWorkersStats cleanup;
} PVWorkersUsage;
/* GUC parameters */
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 1988cd874fd..84bfa2970de 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -2066,6 +2066,8 @@ PVIndStats
PVIndVacStatus
PVOID
PVShared
+PVWorkersUsage
+PVWorkersStats
PX_Alias
PX_Cipher
PX_Combo
--
2.43.0