From 7f5a774d4262e10be077bed8cb6d5808ceb7a7d2 Mon Sep 17 00:00:00 2001
From: Daniil Davidov <d.davydov@postgrespro.ru>
Date: Thu, 2 Apr 2026 04:20:35 +0700
Subject: [PATCH] v35--v36-diff

---
 doc/src/sgml/maintenance.sgml          | 25 +++++++++++++------------
 src/backend/access/common/reloptions.c |  3 ++-
 src/backend/commands/vacuumparallel.c  |  2 +-
 src/backend/utils/misc/guc.c           |  5 +++--
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index eb6a07e086d..884ac898065 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -1179,23 +1179,24 @@ analyze threshold = analyze base threshold + analyze scale factor * number of tu
     phases in parallel using background workers (for the details of each
     vacuum phase, please refer to <xref linkend="vacuum-phases"/>). The
     degree of parallelism is determined by the number of indexes on the
-    relation that support parallel vacuum, limited by the <literal>PARALLEL</literal>
-    (for manual <command>VACUUM</command>) or the
-    <xref linkend="guc-autovacuum-max-parallel-workers"/> parameters (for
-    autovacuum).
+    relation that support parallel vacuum.  For manual <command>VACUUM</command>
+    it is limited by the <literal>PARALLEL</literal> option if any which is
+    further limited by <xref linkend="guc-max-parallel-maintenance-workers"/>.
+    For autovacuum it is limited by the <xref linkend="guc-autovacuum-max-workers"/>
+    reloption if specified which is further limited by
+    <xref linkend="guc-autovacuum-max-parallel-workers"/> parameter.  Please
+    note that it is not guaranteed that the number of parallel workers that was
+    calculated will be used during execution.  It is possible for a vacuum to
+    run with fewer workers than specified, or even with no workers at all.
    </para>
 
    <para>
     An index can participate in parallel vacuum if and only if the size of the
     index is more than <xref linkend="guc-min-parallel-index-scan-size"/>.
-    Please note that it is not guaranteed that the number of parallel workers
-    specified in <replaceable class="parameter">integer</replaceable> will be
-    used during execution.  It is possible for a vacuum to run with fewer
-    workers than specified, or even with no workers at all.  Only one worker
-    can be used per index.  So parallel workers are launched only when there
-    are at least <literal>2</literal> indexes in the table.  Workers for
-    vacuum are launched before the start of each phase and exit at the end of
-    the phase.  These behaviors might change in a future release.
+    Only one worker can be used per index.  So parallel workers are launched
+    only when there are at least <literal>2</literal> indexes in the table.
+    Workers for vacuum are launched before the start of each phase and exit at
+    the end of the phase.  These behaviors might change in a future release.
    </para>
   </sect2>
  </sect1>
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 3e832c3797e..d675d52531c 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -28,6 +28,7 @@
 #include "commands/defrem.h"
 #include "commands/tablespace.h"
 #include "nodes/makefuncs.h"
+#include "postmaster/bgworker_internals.h"
 #include "storage/lock.h"
 #include "utils/array.h"
 #include "utils/attoptcache.h"
@@ -243,7 +244,7 @@ static relopt_int intRelOpts[] =
 			RELOPT_KIND_HEAP,
 			ShareUpdateExclusiveLock
 		},
-		-1, -1, 1024
+		-1, -1, MAX_PARALLEL_WORKER_LIMIT
 	},
 	{
 		{
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index 683a0f34e24..bac3bd28214 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -70,7 +70,7 @@ typedef struct PVSharedCostParams
 	/*
 	 * The generation counter is incremented by the leader process each time
 	 * it updates the shared cost-based vacuum delay parameters. Parallel
-	 * vacuum workers compares it with their local generation,
+	 * vacuum workers compare it with their local generation,
 	 * shared_params_generation_local, to detect whether they need to refresh
 	 * their local parameters. The generation starts from 1 so that a freshly
 	 * started worker (whose local copy is 0) will always load the initial
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 15048aa9e56..c4c3fbc4fe3 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -3359,10 +3359,11 @@ set_config_with_handle(const char *name, config_handle *handle,
 	 * Also allow normal setting if the GUC is marked GUC_ALLOW_IN_PARALLEL.
 	 *
 	 * Other changes might need to affect other workers, so forbid them. Note,
-	 * that parallel autovacuum leader is an exception because only cost-based
+	 * that parallel autovacuum leader is an exception because cost-based
 	 * delays need to be affected to parallel autovacuum workers. These
 	 * parameters are propagated to its workers during parallel vacuum (see
-	 * vacuumparallel.c for details).
+	 * vacuumparallel.c for details). All other changes will affect only the
+	 * parallel autovacuum leader.
 	 */
 	if (IsInParallelMode() && !AmAutoVacuumWorkerProcess() && changeVal &&
 		action != GUC_ACTION_SAVE &&
-- 
2.43.0

