Skip to content

Commit 39d4207

Browse files
committed
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
1 parent cd59fcf commit 39d4207

File tree

11 files changed

+42
-42
lines changed

11 files changed

+42
-42
lines changed

doc/src/sgml/config.sgml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11743,10 +11743,10 @@ LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
1174311743
</listitem>
1174411744
</varlistentry>
1174511745

11746-
<varlistentry id="guc-logical-replication-mode" xreflabel="logical_replication_mode">
11747-
<term><varname>logical_replication_mode</varname> (<type>enum</type>)
11746+
<varlistentry id="guc-debug-logical-replication-streaming" xreflabel="debug_logical_replication_streaming">
11747+
<term><varname>debug_logical_replication_streaming</varname> (<type>enum</type>)
1174811748
<indexterm>
11749-
<primary><varname>logical_replication_mode</varname> configuration parameter</primary>
11749+
<primary><varname>debug_logical_replication_streaming</varname> configuration parameter</primary>
1175011750
</indexterm>
1175111751
</term>
1175211752
<listitem>
@@ -11755,12 +11755,12 @@ LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
1175511755
<literal>immediate</literal>. The default is <literal>buffered</literal>.
1175611756
This parameter is intended to be used to test logical decoding and
1175711757
replication of large transactions. The effect of
11758-
<varname>logical_replication_mode</varname> is different for the
11758+
<varname>debug_logical_replication_streaming</varname> is different for the
1175911759
publisher and subscriber:
1176011760
</para>
1176111761

1176211762
<para>
11763-
On the publisher side, <varname>logical_replication_mode</varname>
11763+
On the publisher side, <varname>debug_logical_replication_streaming</varname>
1176411764
allows streaming or serializing changes immediately in logical decoding.
1176511765
When set to <literal>immediate</literal>, stream each change if the
1176611766
<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)
1177311773

1177411774
<para>
1177511775
On the subscriber side, if the <literal>streaming</literal> option is set to
11776-
<literal>parallel</literal>, <varname>logical_replication_mode</varname>
11776+
<literal>parallel</literal>, <varname>debug_logical_replication_streaming</varname>
1177711777
can be used to direct the leader apply worker to send changes to the
1177811778
shared memory queue or to serialize all changes to the file. When set to
1177911779
<literal>buffered</literal>, the leader sends changes to parallel apply

doc/src/sgml/release-16.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ Author: Amit Kapila <akapila@postgresql.org>
17091709

17101710
<para>
17111711
The variable is <link
1712-
linkend="guc-logical-replication-mode"><varname>logical_replication_mode</varname></link>.
1712+
linkend="guc-debug-logical-replication-streaming"><varname>debug_logical_replication_streaming</varname></link>.
17131713
</para>
17141714
</listitem>
17151715

src/backend/replication/logical/applyparallelworker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ pa_send_data(ParallelApplyWorkerInfo *winfo, Size nbytes, const void *data)
11591159
* We don't try to send data to parallel worker for 'immediate' mode. This
11601160
* is primarily used for testing purposes.
11611161
*/
1162-
if (unlikely(logical_replication_mode == LOGICAL_REP_MODE_IMMEDIATE))
1162+
if (unlikely(debug_logical_replication_streaming == DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE))
11631163
return false;
11641164

11651165
/*

src/backend/replication/logical/reorderbuffer.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ int logical_decoding_work_mem;
210210
static const Size max_changes_in_memory = 4096; /* XXX for restore only */
211211

212212
/* GUC variable */
213-
int logical_replication_mode = LOGICAL_REP_MODE_BUFFERED;
213+
int debug_logical_replication_streaming = DEBUG_LOGICAL_REP_STREAMING_BUFFERED;
214214

215215
/* ---------------------------------------
216216
* primary reorderbuffer support routines
@@ -3566,8 +3566,8 @@ ReorderBufferLargestStreamableTopTXN(ReorderBuffer *rb)
35663566
* pick the largest (sub)transaction at-a-time to evict and spill its changes to
35673567
* disk or send to the output plugin until we reach under the memory limit.
35683568
*
3569-
* If logical_replication_mode is set to "immediate", stream or serialize the
3570-
* changes immediately.
3569+
* If debug_logical_replication_streaming is set to "immediate", stream or
3570+
* serialize the changes immediately.
35713571
*
35723572
* XXX At this point we select the transactions until we reach under the memory
35733573
* limit, but we might also adapt a more elaborate eviction strategy - for example
@@ -3580,25 +3580,25 @@ ReorderBufferCheckMemoryLimit(ReorderBuffer *rb)
35803580
ReorderBufferTXN *txn;
35813581

35823582
/*
3583-
* Bail out if logical_replication_mode is buffered and we haven't
3584-
* exceeded the memory limit.
3583+
* Bail out if debug_logical_replication_streaming is buffered and we
3584+
* haven't exceeded the memory limit.
35853585
*/
3586-
if (logical_replication_mode == LOGICAL_REP_MODE_BUFFERED &&
3586+
if (debug_logical_replication_streaming == DEBUG_LOGICAL_REP_STREAMING_BUFFERED &&
35873587
rb->size < logical_decoding_work_mem * 1024L)
35883588
return;
35893589

35903590
/*
3591-
* If logical_replication_mode is immediate, loop until there's no change.
3592-
* Otherwise, loop until we reach under the memory limit. One might think
3593-
* that just by evicting the largest (sub)transaction we will come under
3594-
* the memory limit based on assumption that the selected transaction is
3595-
* at least as large as the most recent change (which caused us to go over
3596-
* the memory limit). However, that is not true because a user can reduce
3597-
* the logical_decoding_work_mem to a smaller value before the most recent
3598-
* change.
3591+
* If debug_logical_replication_streaming is immediate, loop until there's
3592+
* no change. Otherwise, loop until we reach under the memory limit. One
3593+
* might think that just by evicting the largest (sub)transaction we will
3594+
* come under the memory limit based on assumption that the selected
3595+
* transaction is at least as large as the most recent change (which
3596+
* caused us to go over the memory limit). However, that is not true
3597+
* because a user can reduce the logical_decoding_work_mem to a smaller
3598+
* value before the most recent change.
35993599
*/
36003600
while (rb->size >= logical_decoding_work_mem * 1024L ||
3601-
(logical_replication_mode == LOGICAL_REP_MODE_IMMEDIATE &&
3601+
(debug_logical_replication_streaming == DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE &&
36023602
rb->size > 0))
36033603
{
36043604
/*

src/backend/utils/misc/guc_tables.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ static const struct config_enum_entry ssl_protocol_versions_info[] = {
413413
{NULL, 0, false}
414414
};
415415

416-
static const struct config_enum_entry logical_replication_mode_options[] = {
417-
{"buffered", LOGICAL_REP_MODE_BUFFERED, false},
418-
{"immediate", LOGICAL_REP_MODE_IMMEDIATE, false},
416+
static const struct config_enum_entry debug_logical_replication_streaming_options[] = {
417+
{"buffered", DEBUG_LOGICAL_REP_STREAMING_BUFFERED, false},
418+
{"immediate", DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE, false},
419419
{NULL, 0, false}
420420
};
421421

@@ -4956,15 +4956,15 @@ struct config_enum ConfigureNamesEnum[] =
49564956
},
49574957

49584958
{
4959-
{"logical_replication_mode", PGC_USERSET, DEVELOPER_OPTIONS,
4960-
gettext_noop("Controls when to replicate or apply each change."),
4959+
{"debug_logical_replication_streaming", PGC_USERSET, DEVELOPER_OPTIONS,
4960+
gettext_noop("Forces immediate streaming or serialization of changes in large transactions."),
49614961
gettext_noop("On the publisher, it allows streaming or serializing each change in logical decoding. "
49624962
"On the subscriber, it allows serialization of all changes to files and notifies the "
49634963
"parallel apply workers to read and apply them at the end of the transaction."),
49644964
GUC_NOT_IN_SAMPLE
49654965
},
4966-
&logical_replication_mode,
4967-
LOGICAL_REP_MODE_BUFFERED, logical_replication_mode_options,
4966+
&debug_logical_replication_streaming,
4967+
DEBUG_LOGICAL_REP_STREAMING_BUFFERED, debug_logical_replication_streaming_options,
49684968
NULL, NULL, NULL
49694969
},
49704970

src/include/replication/reorderbuffer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
/* GUC variables */
2121
extern PGDLLIMPORT int logical_decoding_work_mem;
22-
extern PGDLLIMPORT int logical_replication_mode;
22+
extern PGDLLIMPORT int debug_logical_replication_streaming;
2323

24-
/* possible values for logical_replication_mode */
24+
/* possible values for debug_logical_replication_streaming */
2525
typedef enum
2626
{
27-
LOGICAL_REP_MODE_BUFFERED,
28-
LOGICAL_REP_MODE_IMMEDIATE
29-
} LogicalRepMode;
27+
DEBUG_LOGICAL_REP_STREAMING_BUFFERED,
28+
DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE
29+
} DebugLogicalRepStreamingMode;
3030

3131
/* an individual tuple, stored in one chunk of memory */
3232
typedef struct ReorderBufferTupleBuf

src/test/subscription/t/015_stream.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ sub test_streaming
295295
# Test serializing changes to files and notify the parallel apply worker to
296296
# apply them at the end of the transaction.
297297
$node_subscriber->append_conf('postgresql.conf',
298-
'logical_replication_mode = immediate');
298+
'debug_logical_replication_streaming = immediate');
299299
# Reset the log_min_messages to default.
300300
$node_subscriber->append_conf('postgresql.conf',
301301
"log_min_messages = warning");

src/test/subscription/t/016_stream_subxact.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ sub test_streaming
7979
my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
8080
$node_publisher->init(allows_streaming => 'logical');
8181
$node_publisher->append_conf('postgresql.conf',
82-
'logical_replication_mode = immediate');
82+
'debug_logical_replication_streaming = immediate');
8383
$node_publisher->start;
8484

8585
# Create subscriber node

src/test/subscription/t/018_stream_subxact_abort.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ sub test_streaming
130130
my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
131131
$node_publisher->init(allows_streaming => 'logical');
132132
$node_publisher->append_conf('postgresql.conf',
133-
'logical_replication_mode = immediate');
133+
'debug_logical_replication_streaming = immediate');
134134
$node_publisher->start;
135135

136136
# Create subscriber node
@@ -203,7 +203,7 @@ sub test_streaming
203203
# Test serializing changes to files and notify the parallel apply worker to
204204
# apply them at the end of the transaction.
205205
$node_subscriber->append_conf('postgresql.conf',
206-
'logical_replication_mode = immediate');
206+
'debug_logical_replication_streaming = immediate');
207207
# Reset the log_min_messages to default.
208208
$node_subscriber->append_conf('postgresql.conf',
209209
"log_min_messages = warning");

src/test/subscription/t/019_stream_subxact_ddl_abort.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
1717
$node_publisher->init(allows_streaming => 'logical');
1818
$node_publisher->append_conf('postgresql.conf',
19-
'logical_replication_mode = immediate');
19+
'debug_logical_replication_streaming = immediate');
2020
$node_publisher->start;
2121

2222
# Create subscriber node

src/test/subscription/t/023_twophase_stream.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ sub test_streaming
301301
$node_publisher->append_conf(
302302
'postgresql.conf', qq(
303303
max_prepared_transactions = 10
304-
logical_replication_mode = immediate
304+
debug_logical_replication_streaming = immediate
305305
));
306306
$node_publisher->start;
307307

@@ -389,7 +389,7 @@ sub test_streaming
389389
# Test serializing changes to files and notify the parallel apply worker to
390390
# apply them at the end of the transaction.
391391
$node_subscriber->append_conf('postgresql.conf',
392-
'logical_replication_mode = immediate');
392+
'debug_logical_replication_streaming = immediate');
393393
# Reset the log_min_messages to default.
394394
$node_subscriber->append_conf('postgresql.conf',
395395
"log_min_messages = warning");

0 commit comments

Comments
 (0)