Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 079d0ca

Browse files
author
Amit Kapila
committed
Fix the logical replication from HEAD to lower versions.
Commit 4648243 changed the logical replication protocol to allow the streaming of in-progress transactions and used the new version of protocol irrespective of the server version. Use the appropriate version of the protocol based on the server version. Reported-by: Ashutosh Sharma Author: Dilip Kumar Reviewed-by: Ashutosh Sharma and Amit Kapila Discussion: https://postgr.es/m/CAE9k0P=9OpXcNrcU5Gsvd5MZ8GFpiN833vNHzX6Uc=8+h1ft1Q@mail.gmail.com
1 parent dee663f commit 079d0ca

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/backend/replication/logical/worker.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -3087,7 +3087,9 @@ ApplyWorkerMain(Datum main_arg)
30873087
options.logical = true;
30883088
options.startpoint = origin_startpos;
30893089
options.slotname = myslotname;
3090-
options.proto.logical.proto_version = LOGICALREP_PROTO_VERSION_NUM;
3090+
options.proto.logical.proto_version =
3091+
walrcv_server_version(wrconn) >= 140000 ?
3092+
LOGICALREP_PROTO_STREAM_VERSION_NUM : LOGICALREP_PROTO_VERSION_NUM;
30913093
options.proto.logical.publication_names = MySubscription->publications;
30923094
options.proto.logical.binary = MySubscription->binary;
30933095
options.proto.logical.streaming = MySubscription->stream;

src/backend/replication/pgoutput/pgoutput.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
272272
&enable_streaming);
273273

274274
/* Check if we support requested protocol */
275-
if (data->protocol_version > LOGICALREP_PROTO_VERSION_NUM)
275+
if (data->protocol_version > LOGICALREP_PROTO_MAX_VERSION_NUM)
276276
ereport(ERROR,
277277
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
278278
errmsg("client sent proto_version=%d but we only support protocol %d or lower",
279-
data->protocol_version, LOGICALREP_PROTO_VERSION_NUM)));
279+
data->protocol_version, LOGICALREP_PROTO_MAX_VERSION_NUM)));
280280

281281
if (data->protocol_version < LOGICALREP_PROTO_MIN_VERSION_NUM)
282282
ereport(ERROR,

src/include/replication/logicalproto.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@
1919
/*
2020
* Protocol capabilities
2121
*
22-
* LOGICALREP_PROTO_VERSION_NUM is our native protocol and the greatest version
23-
* we can support. LOGICALREP_PROTO_MIN_VERSION_NUM is the oldest version we
22+
* LOGICALREP_PROTO_VERSION_NUM is our native protocol.
23+
* LOGICALREP_PROTO_MAX_VERSION_NUM is the greatest version we can support.
24+
* LOGICALREP_PROTO_MIN_VERSION_NUM is the oldest version we
2425
* have backwards compatibility for. The client requests protocol version at
2526
* connect time.
2627
*
2728
* LOGICALREP_PROTO_STREAM_VERSION_NUM is the minimum protocol version with
2829
* support for streaming large transactions.
2930
*/
3031
#define LOGICALREP_PROTO_MIN_VERSION_NUM 1
32+
#define LOGICALREP_PROTO_VERSION_NUM 1
3133
#define LOGICALREP_PROTO_STREAM_VERSION_NUM 2
32-
#define LOGICALREP_PROTO_VERSION_NUM 2
34+
#define LOGICALREP_PROTO_MAX_VERSION_NUM LOGICALREP_PROTO_STREAM_VERSION_NUM
3335

3436
/*
3537
* This struct stores a tuple received via logical replication.

0 commit comments

Comments
 (0)