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

Commit d38ad8e

Browse files
author
Amit Kapila
committed
Fix the display of UNKNOWN message type in apply worker.
We include the message type while displaying an error context in the apply worker. Now, while retrieving the message type string if the message type is unknown we throw an error that will hide the original error. So, instead, we need to simply return the string indicating an unknown message type. Reported-by: Ashutosh Bapat Author: Euler Taveira, Amit Kapila Reviewed-by: Ashutosh Bapat Backpatch-through: 15 Discussion: https://postgr.es/m/CAExHW5suAEDW-mBZt_qu4RVxWZ1vL54-L+ci2zreYWebpzxYsA@mail.gmail.com
1 parent f3bc519 commit d38ad8e

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/backend/replication/logical/proto.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -1213,9 +1213,11 @@ logicalrep_read_stream_abort(StringInfo in,
12131213
/*
12141214
* Get string representing LogicalRepMsgType.
12151215
*/
1216-
char *
1216+
const char *
12171217
logicalrep_message_type(LogicalRepMsgType action)
12181218
{
1219+
static char err_unknown[20];
1220+
12191221
switch (action)
12201222
{
12211223
case LOGICAL_REP_MSG_BEGIN:
@@ -1258,7 +1260,12 @@ logicalrep_message_type(LogicalRepMsgType action)
12581260
return "STREAM PREPARE";
12591261
}
12601262

1261-
elog(ERROR, "invalid logical replication message type \"%c\"", action);
1263+
/*
1264+
* This message provides context in the error raised when applying a
1265+
* logical message. So we can't throw an error here. Return an unknown
1266+
* indicator value so that the original error is still reported.
1267+
*/
1268+
snprintf(err_unknown, sizeof(err_unknown), "??? (%d)", action);
12621269

1263-
return NULL; /* keep compiler quiet */
1270+
return err_unknown;
12641271
}

src/backend/replication/logical/worker.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3367,7 +3367,7 @@ apply_dispatch(StringInfo s)
33673367
default:
33683368
ereport(ERROR,
33693369
(errcode(ERRCODE_PROTOCOL_VIOLATION),
3370-
errmsg("invalid logical replication message type \"%c\"", action)));
3370+
errmsg("invalid logical replication message type \"??? (%d)\"", action)));
33713371
}
33723372

33733373
/* Reset the current command */

src/include/replication/logicalproto.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,6 @@ extern void logicalrep_write_stream_abort(StringInfo out, TransactionId xid,
269269
extern void logicalrep_read_stream_abort(StringInfo in,
270270
LogicalRepStreamAbortData *abort_data,
271271
bool read_abort_info);
272-
extern char *logicalrep_message_type(LogicalRepMsgType action);
272+
extern const char *logicalrep_message_type(LogicalRepMsgType action);
273273

274274
#endif /* LOGICAL_PROTO_H */

0 commit comments

Comments
 (0)