From de8a835b7793c1deed16462aec3e5dca3933d816 Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Tue, 15 Nov 2022 16:26:32 +1100
Subject: [PATCH v2] Logical replication GUCs - consolidated.

Combines all the logical replication configuration settings on one page
with new Publisher/Subscriber sub-sections.
---
 doc/src/sgml/config.sgml              |  80 +++------------------
 doc/src/sgml/logical-replication.sgml | 130 ++++++++++++++++++++++++++++------
 2 files changed, 120 insertions(+), 90 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 559eb89..4e2559d 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -4162,6 +4162,11 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"'  # Windows
      across the cluster without problems if that is required.
     </para>
 
+    <para>
+     For <firstterm>logical replication</firstterm> configuration settings refer
+     to <xref linkend="logical-replication-config"/>.
+    </para>
+
     <sect2 id="runtime-config-replication-sender">
      <title>Sending Servers</title>
 
@@ -4234,6 +4239,12 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"'  # Windows
          not <link linkend="catalog-pg-replication-origin">pg_replication_origin</link>)
          will prevent the server from starting.
         </para>
+
+        <para>
+         See <xref linkend="logical-replication-config"/> for more details
+         about setting <varname>max_replication_slots</varname> for logical
+         replication.
+        </para>
        </listitem>
       </varlistentry>
 
@@ -4922,75 +4933,6 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
      </variablelist>
     </sect2>
 
-    <sect2 id="runtime-config-replication-subscriber">
-     <title>Subscribers</title>
-
-     <para>
-      These settings control the behavior of a logical replication subscriber.
-      Their values on the publisher are irrelevant.
-     </para>
-
-     <para>
-      Note that <varname>wal_receiver_timeout</varname>,
-      <varname>wal_receiver_status_interval</varname> and
-      <varname>wal_retrieve_retry_interval</varname> configuration parameters
-      affect the logical replication workers as well.
-     </para>
-
-     <variablelist>
-
-     <varlistentry id="guc-max-logical-replication-workers" xreflabel="max_logical_replication_workers">
-      <term><varname>max_logical_replication_workers</varname> (<type>integer</type>)
-      <indexterm>
-       <primary><varname>max_logical_replication_workers</varname> configuration parameter</primary>
-      </indexterm>
-      </term>
-      <listitem>
-       <para>
-        Specifies maximum number of logical replication workers. This includes
-        both apply workers and table synchronization workers.
-       </para>
-       <para>
-        Logical replication workers are taken from the pool defined by
-        <varname>max_worker_processes</varname>.
-       </para>
-       <para>
-        The default value is 4. This parameter can only be set at server
-        start.
-       </para>
-      </listitem>
-     </varlistentry>
-
-     <varlistentry id="guc-max-sync-workers-per-subscription" xreflabel="max_sync_workers_per_subscription">
-      <term><varname>max_sync_workers_per_subscription</varname> (<type>integer</type>)
-      <indexterm>
-       <primary><varname>max_sync_workers_per_subscription</varname> configuration parameter</primary>
-      </indexterm>
-      </term>
-      <listitem>
-       <para>
-        Maximum number of synchronization workers per subscription. This
-        parameter controls the amount of parallelism of the initial data copy
-        during the subscription initialization or when new tables are added.
-       </para>
-       <para>
-        Currently, there can be only one synchronization worker per table.
-       </para>
-       <para>
-        The synchronization workers are taken from the pool defined by
-        <varname>max_logical_replication_workers</varname>.
-       </para>
-       <para>
-        The default value is 2. This parameter can only be set in the
-        <filename>postgresql.conf</filename> file or on the server command
-        line.
-       </para>
-      </listitem>
-     </varlistentry>
-
-     </variablelist>
-    </sect2>
-
    </sect1>
 
    <sect1 id="runtime-config-query">
diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml
index f875638..4e07392 100644
--- a/doc/src/sgml/logical-replication.sgml
+++ b/doc/src/sgml/logical-replication.sgml
@@ -1768,28 +1768,116 @@ CONTEXT:  processing remote data for replication origin "pg_16395" during "INSER
    Logical replication requires several configuration options to be set.
   </para>
 
-  <para>
-   On the publisher side, <varname>wal_level</varname> must be set to
-   <literal>logical</literal>, and <varname>max_replication_slots</varname>
-   must be set to at least the number of subscriptions expected to connect,
-   plus some reserve for table synchronization.  And
-   <varname>max_wal_senders</varname> should be set to at least the same as
-   <varname>max_replication_slots</varname> plus the number of physical
-   replicas that are connected at the same time.
-  </para>
+  <sect2 id="logical-replication-config-publisher">
+   <title>Publishers</title>
+
+   <para>
+    <varname>wal_level</varname> must be set to <literal>logical</literal>.
+   </para>
+
+   <para>
+    <varname>max_replication_slots</varname> must be set to at least the number
+    of subscriptions expected to connect, plus some reserve for table
+    synchronization.
+   </para>
+
+   <para>
+    <varname>max_wal_senders</varname> should be set to at least the same as
+    <varname>max_replication_slots</varname>, plus the number of physical
+    replicas that are connected at the same time.
+   </para>
+
+  </sect2>
+
+  <sect2 id="logical-replication-config-subscriber">
+   <title>Subscribers</title>
+
+   <para>
+    <varname>max_replication_slots</varname> must be set to at least the number
+    of subscriptions that will be added to the subscriber, plus some reserve for
+    table synchronization.
+   </para>
+
+   <para>
+    The following settings control the behavior of a logical replication subscriber.
+    Their values on the publisher are irrelevant:
+   </para>
+
+   <variablelist>
+
+    <varlistentry id="guc-max-logical-replication-workers" xreflabel="max_logical_replication_workers">
+     <term><varname>max_logical_replication_workers</varname> (<type>integer</type>)
+     <indexterm>
+      <primary><varname>max_logical_replication_workers</varname> configuration parameter</primary>
+     </indexterm>
+     </term>
+     <listitem>
+      <para>
+       Specifies maximum number of logical replication workers. This must be set
+       to at least the number of subscriptions (for apply workers), plus some
+       reserve for the table synchronization workers.
+      </para>
+      <para>
+       Logical replication workers are taken from the pool defined by
+       <varname>max_worker_processes</varname>.
+      </para>
+      <para>
+       The default value is 4. This parameter can only be set at server
+       start.
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry id="guc-max-sync-workers-per-subscription" xreflabel="max_sync_workers_per_subscription">
+     <term><varname>max_sync_workers_per_subscription</varname> (<type>integer</type>)
+     <indexterm>
+      <primary><varname>max_sync_workers_per_subscription</varname> configuration parameter</primary>
+     </indexterm>
+     </term>
+     <listitem>
+      <para>
+       Maximum number of synchronization workers per subscription. This
+       parameter controls the amount of parallelism of the initial data copy
+       during the subscription initialization or when new tables are added.
+      </para>
+      <para>
+       Currently, there can be only one synchronization worker per table.
+      </para>
+      <para>
+       The synchronization workers are taken from the pool defined by
+       <varname>max_logical_replication_workers</varname>.
+      </para>
+      <para>
+       The default value is 2. This parameter can only be set in the
+       <filename>postgresql.conf</filename> file or on the server command
+       line.
+      </para>
+     </listitem>
+    </varlistentry>
+
+   </variablelist>
+  </sect2>
+
+  <sect2 id="logical-replication-config-notes">
+   <title>Notes</title>
+
+   <para>
+    <varname>wal_receiver_timeout</varname>,
+    <varname>wal_receiver_status_interval</varname> and
+    <varname>wal_retrieve_retry_interval</varname> configuration parameters
+    affect the logical replication workers as well.
+   </para>
+
+   <para>
+    <varname>max_worker_processes</varname> may need to be adjusted to
+    accommodate for replication workers, at least
+    <varname>max_logical_replication_workers</varname> + <literal>1</literal>.
+    Note that some extensions and parallel queries also take worker slots
+    from <varname>max_worker_processes</varname>.
+   </para>
+
+  </sect2>
 
-  <para>
-   <varname>max_replication_slots</varname> must also be set on the subscriber.
-   It should be set to at least the number of subscriptions that will be added
-   to the subscriber, plus some reserve for table synchronization.
-   <varname>max_logical_replication_workers</varname> must be set to at least
-   the number of subscriptions, again plus some reserve for the table
-   synchronization.  Additionally the <varname>max_worker_processes</varname>
-   may need to be adjusted to accommodate for replication workers, at least
-   (<varname>max_logical_replication_workers</varname>
-   + <literal>1</literal>).  Note that some extensions and parallel queries
-   also take worker slots from <varname>max_worker_processes</varname>.
-  </para>
  </sect1>
 
  <sect1 id="logical-replication-quick-setup">
-- 
1.8.3.1

