Skip to content

Commit 1e8b617

Browse files
author
Amit Kapila
committed
Rename GUC logical_decoding_mode to logical_replication_mode.
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 streaming or serializing each change in logical decoding. In the upcoming patch, 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
1 parent 8d2c191 commit 1e8b617

File tree

9 files changed

+30
-29
lines changed

9 files changed

+30
-29
lines changed

doc/src/sgml/config.sgml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11693,16 +11693,16 @@ LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
1169311693
</listitem>
1169411694
</varlistentry>
1169511695

11696-
<varlistentry id="guc-logical-decoding-mode" xreflabel="logical_decoding_mode">
11697-
<term><varname>logical_decoding_mode</varname> (<type>enum</type>)
11696+
<varlistentry id="guc-logical-replication-mode" xreflabel="logical_replication_mode">
11697+
<term><varname>logical_replication_mode</varname> (<type>enum</type>)
1169811698
<indexterm>
11699-
<primary><varname>logical_decoding_mode</varname> configuration parameter</primary>
11699+
<primary><varname>logical_replication_mode</varname> configuration parameter</primary>
1170011700
</indexterm>
1170111701
</term>
1170211702
<listitem>
1170311703
<para>
1170411704
Allows streaming or serializing changes immediately in logical decoding.
11705-
The allowed values of <varname>logical_decoding_mode</varname> are
11705+
The allowed values of <varname>logical_replication_mode</varname> are
1170611706
<literal>buffered</literal> and <literal>immediate</literal>. When set
1170711707
to <literal>immediate</literal>, stream each change if
1170811708
<literal>streaming</literal> option (see optional parameters set by

src/backend/replication/logical/reorderbuffer.c

Lines changed: 7 additions & 7 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_decoding_mode = LOGICAL_DECODING_MODE_BUFFERED;
213+
int logical_replication_mode = LOGICAL_REP_MODE_BUFFERED;
214214

215215
/* ---------------------------------------
216216
* primary reorderbuffer support routines
@@ -3552,8 +3552,8 @@ ReorderBufferLargestStreamableTopTXN(ReorderBuffer *rb)
35523552
* pick the largest (sub)transaction at-a-time to evict and spill its changes to
35533553
* disk or send to the output plugin until we reach under the memory limit.
35543554
*
3555-
* If logical_decoding_mode is set to "immediate", stream or serialize the changes
3556-
* immediately.
3555+
* If logical_replication_mode is set to "immediate", stream or serialize the
3556+
* changes immediately.
35573557
*
35583558
* XXX At this point we select the transactions until we reach under the memory
35593559
* limit, but we might also adapt a more elaborate eviction strategy - for example
@@ -3566,15 +3566,15 @@ ReorderBufferCheckMemoryLimit(ReorderBuffer *rb)
35663566
ReorderBufferTXN *txn;
35673567

35683568
/*
3569-
* Bail out if logical_decoding_mode is buffered and we haven't exceeded
3569+
* Bail out if logical_replication_mode is buffered and we haven't exceeded
35703570
* the memory limit.
35713571
*/
3572-
if (logical_decoding_mode == LOGICAL_DECODING_MODE_BUFFERED &&
3572+
if (logical_replication_mode == LOGICAL_REP_MODE_BUFFERED &&
35733573
rb->size < logical_decoding_work_mem * 1024L)
35743574
return;
35753575

35763576
/*
3577-
* If logical_decoding_mode is immediate, loop until there's no change.
3577+
* If logical_replication_mode is immediate, loop until there's no change.
35783578
* Otherwise, loop until we reach under the memory limit. One might think
35793579
* that just by evicting the largest (sub)transaction we will come under
35803580
* the memory limit based on assumption that the selected transaction is
@@ -3584,7 +3584,7 @@ ReorderBufferCheckMemoryLimit(ReorderBuffer *rb)
35843584
* change.
35853585
*/
35863586
while (rb->size >= logical_decoding_work_mem * 1024L ||
3587-
(logical_decoding_mode == LOGICAL_DECODING_MODE_IMMEDIATE &&
3587+
(logical_replication_mode == LOGICAL_REP_MODE_IMMEDIATE &&
35883588
rb->size > 0))
35893589
{
35903590
/*

src/backend/utils/misc/guc_tables.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,9 @@ static const struct config_enum_entry ssl_protocol_versions_info[] = {
395395
{NULL, 0, false}
396396
};
397397

398-
static const struct config_enum_entry logical_decoding_mode_options[] = {
399-
{"buffered", LOGICAL_DECODING_MODE_BUFFERED, false},
400-
{"immediate", LOGICAL_DECODING_MODE_IMMEDIATE, false},
398+
static const struct config_enum_entry logical_replication_mode_options[] = {
399+
{"buffered", LOGICAL_REP_MODE_BUFFERED, false},
400+
{"immediate", LOGICAL_REP_MODE_IMMEDIATE, false},
401401
{NULL, 0, false}
402402
};
403403

@@ -4919,13 +4919,13 @@ struct config_enum ConfigureNamesEnum[] =
49194919
},
49204920

49214921
{
4922-
{"logical_decoding_mode", PGC_USERSET, DEVELOPER_OPTIONS,
4923-
gettext_noop("Allows streaming or serializing each change in logical decoding."),
4924-
NULL,
4922+
{"logical_replication_mode", PGC_USERSET, DEVELOPER_OPTIONS,
4923+
gettext_noop("Controls when to replicate each change."),
4924+
gettext_noop("On the publisher, it allows streaming or serializing each change in logical decoding."),
49254925
GUC_NOT_IN_SAMPLE
49264926
},
4927-
&logical_decoding_mode,
4928-
LOGICAL_DECODING_MODE_BUFFERED, logical_decoding_mode_options,
4927+
&logical_replication_mode,
4928+
LOGICAL_REP_MODE_BUFFERED, logical_replication_mode_options,
49294929
NULL, NULL, NULL
49304930
},
49314931

src/include/replication/reorderbuffer.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
#include "utils/snapshot.h"
1818
#include "utils/timestamp.h"
1919

20+
/* GUC variables */
2021
extern PGDLLIMPORT int logical_decoding_work_mem;
21-
extern PGDLLIMPORT int logical_decoding_mode;
22+
extern PGDLLIMPORT int logical_replication_mode;
2223

23-
/* possible values for logical_decoding_mode */
24+
/* possible values for logical_replication_mode */
2425
typedef enum
2526
{
26-
LOGICAL_DECODING_MODE_BUFFERED,
27-
LOGICAL_DECODING_MODE_IMMEDIATE
28-
} LogicalDecodingMode;
27+
LOGICAL_REP_MODE_BUFFERED,
28+
LOGICAL_REP_MODE_IMMEDIATE
29+
} LogicalRepMode;
2930

3031
/* an individual tuple, stored in one chunk of memory */
3132
typedef struct ReorderBufferTupleBuf

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_decoding_mode = immediate');
82+
'logical_replication_mode = immediate');
8383
$node_publisher->start;
8484

8585
# Create subscriber node

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

Lines changed: 1 addition & 1 deletion
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_decoding_mode = immediate');
133+
'logical_replication_mode = immediate');
134134
$node_publisher->start;
135135

136136
# Create subscriber node

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_decoding_mode = immediate');
19+
'logical_replication_mode = immediate');
2020
$node_publisher->start;
2121

2222
# Create subscriber node

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

Lines changed: 1 addition & 1 deletion
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_decoding_mode = immediate
304+
logical_replication_mode = immediate
305305
));
306306
$node_publisher->start;
307307

src/tools/pgindent/typedefs.list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,6 @@ LogicalDecodeStreamStopCB
14581458
LogicalDecodeStreamTruncateCB
14591459
LogicalDecodeTruncateCB
14601460
LogicalDecodingContext
1461-
LogicalDecodingMode
14621461
LogicalErrorCallbackState
14631462
LogicalOutputPluginInit
14641463
LogicalOutputPluginWriterPrepareWrite
@@ -1468,6 +1467,7 @@ LogicalRepBeginData
14681467
LogicalRepCommitData
14691468
LogicalRepCommitPreparedTxnData
14701469
LogicalRepCtxStruct
1470+
LogicalRepMode
14711471
LogicalRepMsgType
14721472
LogicalRepPartMapEntry
14731473
LogicalRepPreparedTxnData

0 commit comments

Comments
 (0)