Rename GUC logical_decoding_mode to logical_replication_mode.
authorAmit Kapila <[email protected]>
Mon, 30 Jan 2023 02:32:08 +0000 (08:02 +0530)
committerAmit Kapila <[email protected]>
Mon, 30 Jan 2023 02:32:08 +0000 (08:02 +0530)
Rename the developer option 'logical_decoding_mode' to the more flexible
name 'logical_replication_mode' because doing so will make it easier to
extend this option in the future to help test other areas of logical
replication.

Currently, it is used on the publisher side to allow  or
serializing each change in logical decoding. In the upcoming , we are
planning to use it on the subscriber. On the subscriber, it will allow
serializing the changes to file and notifies the parallel apply workers to
read and apply them at the end of the transaction.

We discussed exposing this parameter as a subscription option but
it did not seem advisable since it is primarily used for testing/debugging
and there is no other such parameter. We also discussed having separate
GUCs for publisher and subscriber but for current testing/debugging
requirements, one GUC is sufficient.

Author: Hou Zhijie
Reviewed-by: Peter Smith, Kuroda Hayato, Sawada Masahiko, Amit Kapila
Discussion: https://postgr.es/m/CAD21AoAy2c=Mx=FTCs+EwUsf2kQL5MmU3N18X84k0EmCXntK4g@mail.gmail.com
Discussion: https://postgr.es/m/CAA4eK1+wyN6zpaHUkCLorEWNx75MG0xhMwcFhvjqm2KURZEAGw@mail.gmail.com

doc/src/sgml/config.sgml
src/backend/replication/logical/reorderbuffer.c
src/backend/utils/misc/guc_tables.c
src/include/replication/reorderbuffer.h
src/test/subscription/t/016_stream_subxact.pl
src/test/subscription/t/018_stream_subxact_abort.pl
src/test/subscription/t/019_stream_subxact_ddl_abort.pl
src/test/subscription/t/023_twophase_stream.pl
src/tools/pgindent/typedefs.list

index f985afc009d04677618c27c8d57e88b60ecc0659..1cf53c74ea6b6be83c2211fe8115466149b25878 100644 (file)
@@ -11693,16 +11693,16 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
       </listitem>
      </varlistentry>
 
-     <varlistentry id="guc-logical-decoding-mode" xreflabel="logical_decoding_mode">
-      <term><varname>logical_decoding_mode</varname> (<type>enum</type>)
+     <varlistentry id="guc-logical-replication-mode" xreflabel="logical_replication_mode">
+      <term><varname>logical_replication_mode</varname> (<type>enum</type>)
       <indexterm>
-       <primary><varname>logical_decoding_mode</varname> configuration parameter</primary>
+       <primary><varname>logical_replication_mode</varname> configuration parameter</primary>
       </indexterm>
       </term>
       <listitem>
        <para>
         Allows  or serializing changes immediately in logical decoding.
-        The allowed values of <varname>logical_decoding_mode</varname> are
+        The allowed values of <varname>logical_replication_mode</varname> are
         <literal>buffered</literal> and <literal>immediate</literal>. When set
         to <literal>immediate</literal>, stream each change if
         <literal></literal> option (see optional parameters set by
index 54ee824e6c4dd96240f25e4d9e47520e5a8b4c54..efe057b4de2c08ecce15b696fe38b90e5997bcd3 100644 (file)
@@ -210,7 +210,7 @@ int         logical_decoding_work_mem;
 static const Size max_changes_in_memory = 4096; /* XXX for restore only */
 
 /* GUC variable */
-int            logical_decoding_mode = LOGICAL_DECODING_MODE_BUFFERED;
+int            logical_replication_mode = LOGICAL_REP_MODE_BUFFERED;
 
 /* ---------------------------------------
  * primary reorderbuffer support routines
@@ -3552,8 +3552,8 @@ ReorderBufferLargestStreamableTopTXN(ReorderBuffer *rb)
  * pick the largest (sub)transaction at-a-time to evict and spill its changes to
  * disk or send to the output plugin until we reach under the memory limit.
  *
- * If logical_decoding_mode is set to "immediate", stream or serialize the changes
- * immediately.
+ * If logical_replication_mode is set to "immediate", stream or serialize the
+ * changes immediately.
  *
  * XXX At this point we select the transactions until we reach under the memory
  * limit, but we might also adapt a more elaborate eviction strategy - for example
@@ -3566,15 +3566,15 @@ ReorderBufferCheckMemoryLimit(ReorderBuffer *rb)
    ReorderBufferTXN *txn;
 
    /*
-    * Bail out if logical_decoding_mode is buffered and we haven't exceeded
+    * Bail out if logical_replication_mode is buffered and we haven't exceeded
     * the memory limit.
     */
-   if (logical_decoding_mode == LOGICAL_DECODING_MODE_BUFFERED &&
+   if (logical_replication_mode == LOGICAL_REP_MODE_BUFFERED &&
        rb->size < logical_decoding_work_mem * 1024L)
        return;
 
    /*
-    * If logical_decoding_mode is immediate, loop until there's no change.
+    * If logical_replication_mode is immediate, loop until there's no change.
     * Otherwise, loop until we reach under the memory limit. One might think
     * that just by evicting the largest (sub)transaction we will come under
     * the memory limit based on assumption that the selected transaction is
@@ -3584,7 +3584,7 @@ ReorderBufferCheckMemoryLimit(ReorderBuffer *rb)
     * change.
     */
    while (rb->size >= logical_decoding_work_mem * 1024L ||
-          (logical_decoding_mode == LOGICAL_DECODING_MODE_IMMEDIATE &&
+          (logical_replication_mode == LOGICAL_REP_MODE_IMMEDIATE &&
            rb->size > 0))
    {
        /*
index 4ac808ed224867ccc5da59318a78947c70f45643..c5a95f5dcca40dee1a2793e980482d2abc950c4b 100644 (file)
@@ -395,9 +395,9 @@ static const struct config_enum_entry ssl_protocol_versions_info[] = {
    {NULL, 0, false}
 };
 
-static const struct config_enum_entry logical_decoding_mode_options[] = {
-   {"buffered", LOGICAL_DECODING_MODE_BUFFERED, false},
-   {"immediate", LOGICAL_DECODING_MODE_IMMEDIATE, false},
+static const struct config_enum_entry logical_replication_mode_options[] = {
+   {"buffered", LOGICAL_REP_MODE_BUFFERED, false},
+   {"immediate", LOGICAL_REP_MODE_IMMEDIATE, false},
    {NULL, 0, false}
 };
 
@@ -4919,13 +4919,13 @@ struct config_enum ConfigureNamesEnum[] =
    },
 
    {
-       {"logical_decoding_mode", PGC_USERSET, DEVELOPER_OPTIONS,
-           gettext_noop("Allows  or serializing each change in logical decoding."),
-           NULL,
+       {"logical_replication_mode", PGC_USERSET, DEVELOPER_OPTIONS,
+           gettext_noop("Controls when to replicate each change."),
+           gettext_noop("On the publisher, it allows  or serializing each change in logical decoding."),
            GUC_NOT_IN_SAMPLE
        },
-       &logical_decoding_mode,
-       LOGICAL_DECODING_MODE_BUFFERED, logical_decoding_mode_options,
+       &logical_replication_mode,
+       LOGICAL_REP_MODE_BUFFERED, logical_replication_mode_options,
        NULL, NULL, NULL
    },
 
index f6c4dd75db6919d4877e5418f073b4a5132217a9..e5db041df1856c8faa5afbbb12c051c97fb308ba 100644 (file)
 #include "utils/snapshot.h"
 #include "utils/timestamp.h"
 
+/* GUC variables */
 extern PGDLLIMPORT int logical_decoding_work_mem;
-extern PGDLLIMPORT int logical_decoding_mode;
+extern PGDLLIMPORT int logical_replication_mode;
 
-/* possible values for logical_decoding_mode */
+/* possible values for logical_replication_mode */
 typedef enum
 {
-   LOGICAL_DECODING_MODE_BUFFERED,
-   LOGICAL_DECODING_MODE_IMMEDIATE
-} LogicalDecodingMode;
+   LOGICAL_REP_MODE_BUFFERED,
+   LOGICAL_REP_MODE_IMMEDIATE
+} LogicalRepMode;
 
 /* an individual tuple, stored in one chunk of memory */
 typedef struct ReorderBufferTupleBuf
index 2f0148c3a86c101d1b6de73e5e461b440af43945..d830f26e06f4b72ef112e3881b5e44c1620fd3cc 100644 (file)
@@ -79,7 +79,7 @@ sub test_
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 $node_publisher->init(allows_ => 'logical');
 $node_publisher->append_conf('postgresql.conf',
-   'logical_decoding_mode = immediate');
+   'logical_replication_mode = immediate');
 $node_publisher->start;
 
 # Create subscriber node
index dce14b150af72c01d292944e499cb7e9ef29b880..814daf4d2f99ffa367c30b79b528656f49e79128 100644 (file)
@@ -130,7 +130,7 @@ sub test_
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 $node_publisher->init(allows_ => 'logical');
 $node_publisher->append_conf('postgresql.conf',
-   'logical_decoding_mode = immediate');
+   'logical_replication_mode = immediate');
 $node_publisher->start;
 
 # Create subscriber node
index b30223de51b4bd2c4b81d31e95ec5d60dffbe405..d0e556c8b8307f03ad8ea87ad407f9de5868bc7c 100644 (file)
@@ -16,7 +16,7 @@ use Test::More;
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 $node_publisher->init(allows_ => 'logical');
 $node_publisher->append_conf('postgresql.conf',
-   'logical_decoding_mode = immediate');
+   'logical_replication_mode = immediate');
 $node_publisher->start;
 
 # Create subscriber node
index 75ca83765e6b43d12f9ee9d326f43f79a068f74f..497245a209c5fdb95d1ede68b4ff3c630b505356 100644 (file)
@@ -301,7 +301,7 @@ $node_publisher->init(allows_ => 'logical');
 $node_publisher->append_conf(
    'postgresql.conf', qq(
 max_prepared_transactions = 10
-logical_decoding_mode = immediate
+logical_replication_mode = immediate
 ));
 $node_publisher->start;
 
index 51484ca7e2fd6ef474a22748a8d844e109201a07..07fbb7ccf6eee115700c437406b695d692d8dbef 100644 (file)
@@ -1458,7 +1458,6 @@ LogicalDecodeStreamStopCB
 LogicalDecodeStreamTruncateCB
 LogicalDecodeTruncateCB
 LogicalDecodingContext
-LogicalDecodingMode
 LogicalErrorCallbackState
 LogicalOutputPluginInit
 LogicalOutputPluginWriterPrepareWrite
@@ -1468,6 +1467,7 @@ LogicalRepBeginData
 LogicalRepCommitData
 LogicalRepCommitPreparedTxnData
 LogicalRepCtxStruct
+LogicalRepMode
 LogicalRepMsgType
 LogicalRepPartMapEntry
 LogicalRepPreparedTxnData