mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Rename logical_replication_mode to debug_logical_replication_streaming
The logical_replication_mode GUC is intended for testing and debugging purposes, but its current name may be misleading and encourage users to make unnecessary changes. To avoid confusion, renaming the GUC to a less misleading name debug_logical_replication_streaming that casual users are less likely to mistakenly assume needs to be modified in a regular logical replication setup. Author: Hou Zhijie <houzj.fnst@cn.fujitsu.com> Reviewed-by: Peter Smith <smithpb2250@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/d672d774-c44b-6fec-f993-793e744f169a%40eisentraut.org
This commit is contained in:
		@@ -11743,10 +11743,10 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
 | 
				
			|||||||
      </listitem>
 | 
					      </listitem>
 | 
				
			||||||
     </varlistentry>
 | 
					     </varlistentry>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     <varlistentry id="guc-logical-replication-mode" xreflabel="logical_replication_mode">
 | 
					     <varlistentry id="guc-debug-logical-replication-streaming" xreflabel="debug_logical_replication_streaming">
 | 
				
			||||||
      <term><varname>logical_replication_mode</varname> (<type>enum</type>)
 | 
					      <term><varname>debug_logical_replication_streaming</varname> (<type>enum</type>)
 | 
				
			||||||
      <indexterm>
 | 
					      <indexterm>
 | 
				
			||||||
       <primary><varname>logical_replication_mode</varname> configuration parameter</primary>
 | 
					       <primary><varname>debug_logical_replication_streaming</varname> configuration parameter</primary>
 | 
				
			||||||
      </indexterm>
 | 
					      </indexterm>
 | 
				
			||||||
      </term>
 | 
					      </term>
 | 
				
			||||||
      <listitem>
 | 
					      <listitem>
 | 
				
			||||||
@@ -11755,12 +11755,12 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
 | 
				
			|||||||
        <literal>immediate</literal>. The default is <literal>buffered</literal>.
 | 
					        <literal>immediate</literal>. The default is <literal>buffered</literal>.
 | 
				
			||||||
        This parameter is intended to be used to test logical decoding and
 | 
					        This parameter is intended to be used to test logical decoding and
 | 
				
			||||||
        replication of large transactions.  The effect of
 | 
					        replication of large transactions.  The effect of
 | 
				
			||||||
        <varname>logical_replication_mode</varname> is different for the
 | 
					        <varname>debug_logical_replication_streaming</varname> is different for the
 | 
				
			||||||
        publisher and subscriber:
 | 
					        publisher and subscriber:
 | 
				
			||||||
       </para>
 | 
					       </para>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       <para>
 | 
					       <para>
 | 
				
			||||||
        On the publisher side, <varname>logical_replication_mode</varname>
 | 
					        On the publisher side, <varname>debug_logical_replication_streaming</varname>
 | 
				
			||||||
        allows streaming or serializing changes immediately in logical decoding.
 | 
					        allows streaming or serializing changes immediately in logical decoding.
 | 
				
			||||||
        When set to <literal>immediate</literal>, stream each change if the
 | 
					        When set to <literal>immediate</literal>, stream each change if the
 | 
				
			||||||
        <link linkend="sql-createsubscription-with-streaming"><literal>streaming</literal></link>
 | 
					        <link linkend="sql-createsubscription-with-streaming"><literal>streaming</literal></link>
 | 
				
			||||||
@@ -11773,7 +11773,7 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
       <para>
 | 
					       <para>
 | 
				
			||||||
        On the subscriber side, if the <literal>streaming</literal> option is set to
 | 
					        On the subscriber side, if the <literal>streaming</literal> option is set to
 | 
				
			||||||
        <literal>parallel</literal>, <varname>logical_replication_mode</varname>
 | 
					        <literal>parallel</literal>, <varname>debug_logical_replication_streaming</varname>
 | 
				
			||||||
        can be used to direct the leader apply worker to send changes to the
 | 
					        can be used to direct the leader apply worker to send changes to the
 | 
				
			||||||
        shared memory queue or to serialize all changes to the file.  When set to
 | 
					        shared memory queue or to serialize all changes to the file.  When set to
 | 
				
			||||||
        <literal>buffered</literal>, the leader sends changes to parallel apply
 | 
					        <literal>buffered</literal>, the leader sends changes to parallel apply
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1709,7 +1709,7 @@ Author: Amit Kapila <akapila@postgresql.org>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      <para>
 | 
					      <para>
 | 
				
			||||||
       The variable is <link
 | 
					       The variable is <link
 | 
				
			||||||
       linkend="guc-logical-replication-mode"><varname>logical_replication_mode</varname></link>.
 | 
					       linkend="guc-debug-logical-replication-streaming"><varname>debug_logical_replication_streaming</varname></link>.
 | 
				
			||||||
      </para>
 | 
					      </para>
 | 
				
			||||||
     </listitem>
 | 
					     </listitem>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1159,7 +1159,7 @@ pa_send_data(ParallelApplyWorkerInfo *winfo, Size nbytes, const void *data)
 | 
				
			|||||||
	 * We don't try to send data to parallel worker for 'immediate' mode. This
 | 
						 * We don't try to send data to parallel worker for 'immediate' mode. This
 | 
				
			||||||
	 * is primarily used for testing purposes.
 | 
						 * is primarily used for testing purposes.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (unlikely(logical_replication_mode == LOGICAL_REP_MODE_IMMEDIATE))
 | 
						if (unlikely(debug_logical_replication_streaming == DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE))
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -210,7 +210,7 @@ int			logical_decoding_work_mem;
 | 
				
			|||||||
static const Size max_changes_in_memory = 4096; /* XXX for restore only */
 | 
					static const Size max_changes_in_memory = 4096; /* XXX for restore only */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* GUC variable */
 | 
					/* GUC variable */
 | 
				
			||||||
int			logical_replication_mode = LOGICAL_REP_MODE_BUFFERED;
 | 
					int			debug_logical_replication_streaming = DEBUG_LOGICAL_REP_STREAMING_BUFFERED;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ---------------------------------------
 | 
					/* ---------------------------------------
 | 
				
			||||||
 * primary reorderbuffer support routines
 | 
					 * primary reorderbuffer support routines
 | 
				
			||||||
@@ -3566,8 +3566,8 @@ ReorderBufferLargestStreamableTopTXN(ReorderBuffer *rb)
 | 
				
			|||||||
 * pick the largest (sub)transaction at-a-time to evict and spill its changes to
 | 
					 * 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.
 | 
					 * disk or send to the output plugin until we reach under the memory limit.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * If logical_replication_mode is set to "immediate", stream or serialize the
 | 
					 * If debug_logical_replication_streaming is set to "immediate", stream or
 | 
				
			||||||
 * changes immediately.
 | 
					 * serialize the changes immediately.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * XXX At this point we select the transactions until we reach under the memory
 | 
					 * 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
 | 
					 * limit, but we might also adapt a more elaborate eviction strategy - for example
 | 
				
			||||||
@@ -3580,25 +3580,25 @@ ReorderBufferCheckMemoryLimit(ReorderBuffer *rb)
 | 
				
			|||||||
	ReorderBufferTXN *txn;
 | 
						ReorderBufferTXN *txn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Bail out if logical_replication_mode is buffered and we haven't
 | 
						 * Bail out if debug_logical_replication_streaming is buffered and we
 | 
				
			||||||
	 * exceeded the memory limit.
 | 
						 * haven't exceeded the memory limit.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (logical_replication_mode == LOGICAL_REP_MODE_BUFFERED &&
 | 
						if (debug_logical_replication_streaming == DEBUG_LOGICAL_REP_STREAMING_BUFFERED &&
 | 
				
			||||||
		rb->size < logical_decoding_work_mem * 1024L)
 | 
							rb->size < logical_decoding_work_mem * 1024L)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * If logical_replication_mode is immediate, loop until there's no change.
 | 
						 * If debug_logical_replication_streaming is immediate, loop until there's
 | 
				
			||||||
	 * Otherwise, loop until we reach under the memory limit. One might think
 | 
						 * no change. Otherwise, loop until we reach under the memory limit. One
 | 
				
			||||||
	 * that just by evicting the largest (sub)transaction we will come under
 | 
						 * might think that just by evicting the largest (sub)transaction we will
 | 
				
			||||||
	 * the memory limit based on assumption that the selected transaction is
 | 
						 * come under the memory limit based on assumption that the selected
 | 
				
			||||||
	 * at least as large as the most recent change (which caused us to go over
 | 
						 * transaction is at least as large as the most recent change (which
 | 
				
			||||||
	 * the memory limit). However, that is not true because a user can reduce
 | 
						 * caused us to go over the memory limit). However, that is not true
 | 
				
			||||||
	 * the logical_decoding_work_mem to a smaller value before the most recent
 | 
						 * because a user can reduce the logical_decoding_work_mem to a smaller
 | 
				
			||||||
	 * change.
 | 
						 * value before the most recent change.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	while (rb->size >= logical_decoding_work_mem * 1024L ||
 | 
						while (rb->size >= logical_decoding_work_mem * 1024L ||
 | 
				
			||||||
		   (logical_replication_mode == LOGICAL_REP_MODE_IMMEDIATE &&
 | 
							   (debug_logical_replication_streaming == DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE &&
 | 
				
			||||||
			rb->size > 0))
 | 
								rb->size > 0))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -413,9 +413,9 @@ static const struct config_enum_entry ssl_protocol_versions_info[] = {
 | 
				
			|||||||
	{NULL, 0, false}
 | 
						{NULL, 0, false}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct config_enum_entry logical_replication_mode_options[] = {
 | 
					static const struct config_enum_entry debug_logical_replication_streaming_options[] = {
 | 
				
			||||||
	{"buffered", LOGICAL_REP_MODE_BUFFERED, false},
 | 
						{"buffered", DEBUG_LOGICAL_REP_STREAMING_BUFFERED, false},
 | 
				
			||||||
	{"immediate", LOGICAL_REP_MODE_IMMEDIATE, false},
 | 
						{"immediate", DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE, false},
 | 
				
			||||||
	{NULL, 0, false}
 | 
						{NULL, 0, false}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -4956,15 +4956,15 @@ struct config_enum ConfigureNamesEnum[] =
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		{"logical_replication_mode", PGC_USERSET, DEVELOPER_OPTIONS,
 | 
							{"debug_logical_replication_streaming", PGC_USERSET, DEVELOPER_OPTIONS,
 | 
				
			||||||
			gettext_noop("Controls when to replicate or apply each change."),
 | 
								gettext_noop("Forces immediate streaming or serialization of changes in large transactions."),
 | 
				
			||||||
			gettext_noop("On the publisher, it allows streaming or serializing each change in logical decoding. "
 | 
								gettext_noop("On the publisher, it allows streaming or serializing each change in logical decoding. "
 | 
				
			||||||
						 "On the subscriber, it allows serialization of all changes to files and notifies the "
 | 
											 "On the subscriber, it allows serialization of all changes to files and notifies the "
 | 
				
			||||||
						 "parallel apply workers to read and apply them at the end of the transaction."),
 | 
											 "parallel apply workers to read and apply them at the end of the transaction."),
 | 
				
			||||||
			GUC_NOT_IN_SAMPLE
 | 
								GUC_NOT_IN_SAMPLE
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		&logical_replication_mode,
 | 
							&debug_logical_replication_streaming,
 | 
				
			||||||
		LOGICAL_REP_MODE_BUFFERED, logical_replication_mode_options,
 | 
							DEBUG_LOGICAL_REP_STREAMING_BUFFERED, debug_logical_replication_streaming_options,
 | 
				
			||||||
		NULL, NULL, NULL
 | 
							NULL, NULL, NULL
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,14 +19,14 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* GUC variables */
 | 
					/* GUC variables */
 | 
				
			||||||
extern PGDLLIMPORT int logical_decoding_work_mem;
 | 
					extern PGDLLIMPORT int logical_decoding_work_mem;
 | 
				
			||||||
extern PGDLLIMPORT int logical_replication_mode;
 | 
					extern PGDLLIMPORT int debug_logical_replication_streaming;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* possible values for logical_replication_mode */
 | 
					/* possible values for debug_logical_replication_streaming */
 | 
				
			||||||
typedef enum
 | 
					typedef enum
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	LOGICAL_REP_MODE_BUFFERED,
 | 
						DEBUG_LOGICAL_REP_STREAMING_BUFFERED,
 | 
				
			||||||
	LOGICAL_REP_MODE_IMMEDIATE
 | 
						DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE
 | 
				
			||||||
}			LogicalRepMode;
 | 
					}			DebugLogicalRepStreamingMode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* an individual tuple, stored in one chunk of memory */
 | 
					/* an individual tuple, stored in one chunk of memory */
 | 
				
			||||||
typedef struct ReorderBufferTupleBuf
 | 
					typedef struct ReorderBufferTupleBuf
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -295,7 +295,7 @@ is($result, qq(10000), 'data replicated to subscriber after dropping index');
 | 
				
			|||||||
# Test serializing changes to files and notify the parallel apply worker to
 | 
					# Test serializing changes to files and notify the parallel apply worker to
 | 
				
			||||||
# apply them at the end of the transaction.
 | 
					# apply them at the end of the transaction.
 | 
				
			||||||
$node_subscriber->append_conf('postgresql.conf',
 | 
					$node_subscriber->append_conf('postgresql.conf',
 | 
				
			||||||
	'logical_replication_mode = immediate');
 | 
						'debug_logical_replication_streaming = immediate');
 | 
				
			||||||
# Reset the log_min_messages to default.
 | 
					# Reset the log_min_messages to default.
 | 
				
			||||||
$node_subscriber->append_conf('postgresql.conf',
 | 
					$node_subscriber->append_conf('postgresql.conf',
 | 
				
			||||||
	"log_min_messages = warning");
 | 
						"log_min_messages = warning");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,7 +79,7 @@ sub test_streaming
 | 
				
			|||||||
my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 | 
					my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 | 
				
			||||||
$node_publisher->init(allows_streaming => 'logical');
 | 
					$node_publisher->init(allows_streaming => 'logical');
 | 
				
			||||||
$node_publisher->append_conf('postgresql.conf',
 | 
					$node_publisher->append_conf('postgresql.conf',
 | 
				
			||||||
	'logical_replication_mode = immediate');
 | 
						'debug_logical_replication_streaming = immediate');
 | 
				
			||||||
$node_publisher->start;
 | 
					$node_publisher->start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create subscriber node
 | 
					# Create subscriber node
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -130,7 +130,7 @@ sub test_streaming
 | 
				
			|||||||
my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 | 
					my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 | 
				
			||||||
$node_publisher->init(allows_streaming => 'logical');
 | 
					$node_publisher->init(allows_streaming => 'logical');
 | 
				
			||||||
$node_publisher->append_conf('postgresql.conf',
 | 
					$node_publisher->append_conf('postgresql.conf',
 | 
				
			||||||
	'logical_replication_mode = immediate');
 | 
						'debug_logical_replication_streaming = immediate');
 | 
				
			||||||
$node_publisher->start;
 | 
					$node_publisher->start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create subscriber node
 | 
					# Create subscriber node
 | 
				
			||||||
@@ -203,7 +203,7 @@ test_streaming($node_publisher, $node_subscriber, $appname, 1);
 | 
				
			|||||||
# Test serializing changes to files and notify the parallel apply worker to
 | 
					# Test serializing changes to files and notify the parallel apply worker to
 | 
				
			||||||
# apply them at the end of the transaction.
 | 
					# apply them at the end of the transaction.
 | 
				
			||||||
$node_subscriber->append_conf('postgresql.conf',
 | 
					$node_subscriber->append_conf('postgresql.conf',
 | 
				
			||||||
	'logical_replication_mode = immediate');
 | 
						'debug_logical_replication_streaming = immediate');
 | 
				
			||||||
# Reset the log_min_messages to default.
 | 
					# Reset the log_min_messages to default.
 | 
				
			||||||
$node_subscriber->append_conf('postgresql.conf',
 | 
					$node_subscriber->append_conf('postgresql.conf',
 | 
				
			||||||
	"log_min_messages = warning");
 | 
						"log_min_messages = warning");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ use Test::More;
 | 
				
			|||||||
my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 | 
					my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 | 
				
			||||||
$node_publisher->init(allows_streaming => 'logical');
 | 
					$node_publisher->init(allows_streaming => 'logical');
 | 
				
			||||||
$node_publisher->append_conf('postgresql.conf',
 | 
					$node_publisher->append_conf('postgresql.conf',
 | 
				
			||||||
	'logical_replication_mode = immediate');
 | 
						'debug_logical_replication_streaming = immediate');
 | 
				
			||||||
$node_publisher->start;
 | 
					$node_publisher->start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create subscriber node
 | 
					# Create subscriber node
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -301,7 +301,7 @@ $node_publisher->init(allows_streaming => 'logical');
 | 
				
			|||||||
$node_publisher->append_conf(
 | 
					$node_publisher->append_conf(
 | 
				
			||||||
	'postgresql.conf', qq(
 | 
						'postgresql.conf', qq(
 | 
				
			||||||
max_prepared_transactions = 10
 | 
					max_prepared_transactions = 10
 | 
				
			||||||
logical_replication_mode = immediate
 | 
					debug_logical_replication_streaming = immediate
 | 
				
			||||||
));
 | 
					));
 | 
				
			||||||
$node_publisher->start;
 | 
					$node_publisher->start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -389,7 +389,7 @@ test_streaming($node_publisher, $node_subscriber, $appname, 1);
 | 
				
			|||||||
# Test serializing changes to files and notify the parallel apply worker to
 | 
					# Test serializing changes to files and notify the parallel apply worker to
 | 
				
			||||||
# apply them at the end of the transaction.
 | 
					# apply them at the end of the transaction.
 | 
				
			||||||
$node_subscriber->append_conf('postgresql.conf',
 | 
					$node_subscriber->append_conf('postgresql.conf',
 | 
				
			||||||
	'logical_replication_mode = immediate');
 | 
						'debug_logical_replication_streaming = immediate');
 | 
				
			||||||
# Reset the log_min_messages to default.
 | 
					# Reset the log_min_messages to default.
 | 
				
			||||||
$node_subscriber->append_conf('postgresql.conf',
 | 
					$node_subscriber->append_conf('postgresql.conf',
 | 
				
			||||||
	"log_min_messages = warning");
 | 
						"log_min_messages = warning");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user