@@ -226,7 +226,6 @@ typedef struct ApplyErrorCallbackArg
226226 /* Remote node information */
227227 int remote_attnum ; /* -1 if invalid */
228228 TransactionId remote_xid ;
229- TimestampTz ts ; /* commit, rollback, or prepare timestamp */
230229} ApplyErrorCallbackArg ;
231230
232231static ApplyErrorCallbackArg apply_error_callback_arg =
@@ -235,7 +234,6 @@ static ApplyErrorCallbackArg apply_error_callback_arg =
235234 .rel = NULL ,
236235 .remote_attnum = -1 ,
237236 .remote_xid = InvalidTransactionId ,
238- .ts = 0 ,
239237};
240238
241239static MemoryContext ApplyMessageContext = NULL ;
@@ -334,7 +332,7 @@ static void apply_spooled_messages(TransactionId xid, XLogRecPtr lsn);
334332
335333/* Functions for apply error callback */
336334static void apply_error_callback (void * arg );
337- static inline void set_apply_error_context_xact (TransactionId xid , TimestampTz ts );
335+ static inline void set_apply_error_context_xact (TransactionId xid );
338336static inline void reset_apply_error_context_info (void );
339337
340338/*
@@ -787,7 +785,7 @@ apply_handle_begin(StringInfo s)
787785 LogicalRepBeginData begin_data ;
788786
789787 logicalrep_read_begin (s , & begin_data );
790- set_apply_error_context_xact (begin_data .xid , begin_data . committime );
788+ set_apply_error_context_xact (begin_data .xid );
791789
792790 remote_final_lsn = begin_data .final_lsn ;
793791
@@ -839,7 +837,7 @@ apply_handle_begin_prepare(StringInfo s)
839837 errmsg_internal ("tablesync worker received a BEGIN PREPARE message" )));
840838
841839 logicalrep_read_begin_prepare (s , & begin_data );
842- set_apply_error_context_xact (begin_data .xid , begin_data . prepare_time );
840+ set_apply_error_context_xact (begin_data .xid );
843841
844842 remote_final_lsn = begin_data .prepare_lsn ;
845843
@@ -938,7 +936,7 @@ apply_handle_commit_prepared(StringInfo s)
938936 char gid [GIDSIZE ];
939937
940938 logicalrep_read_commit_prepared (s , & prepare_data );
941- set_apply_error_context_xact (prepare_data .xid , prepare_data . commit_time );
939+ set_apply_error_context_xact (prepare_data .xid );
942940
943941 /* Compute GID for two_phase transactions. */
944942 TwoPhaseTransactionGid (MySubscription -> oid , prepare_data .xid ,
@@ -979,7 +977,7 @@ apply_handle_rollback_prepared(StringInfo s)
979977 char gid [GIDSIZE ];
980978
981979 logicalrep_read_rollback_prepared (s , & rollback_data );
982- set_apply_error_context_xact (rollback_data .xid , rollback_data . rollback_time );
980+ set_apply_error_context_xact (rollback_data .xid );
983981
984982 /* Compute GID for two_phase transactions. */
985983 TwoPhaseTransactionGid (MySubscription -> oid , rollback_data .xid ,
@@ -1044,7 +1042,7 @@ apply_handle_stream_prepare(StringInfo s)
10441042 errmsg_internal ("tablesync worker received a STREAM PREPARE message" )));
10451043
10461044 logicalrep_read_stream_prepare (s , & prepare_data );
1047- set_apply_error_context_xact (prepare_data .xid , prepare_data . prepare_time );
1045+ set_apply_error_context_xact (prepare_data .xid );
10481046
10491047 elog (DEBUG1 , "received prepare for streamed transaction %u" , prepare_data .xid );
10501048
@@ -1126,7 +1124,7 @@ apply_handle_stream_start(StringInfo s)
11261124 (errcode (ERRCODE_PROTOCOL_VIOLATION ),
11271125 errmsg_internal ("invalid transaction ID in streamed replication transaction" )));
11281126
1129- set_apply_error_context_xact (stream_xid , 0 );
1127+ set_apply_error_context_xact (stream_xid );
11301128
11311129 /*
11321130 * Initialize the worker's stream_fileset if we haven't yet. This will be
@@ -1215,7 +1213,7 @@ apply_handle_stream_abort(StringInfo s)
12151213 */
12161214 if (xid == subxid )
12171215 {
1218- set_apply_error_context_xact (xid , 0 );
1216+ set_apply_error_context_xact (xid );
12191217 stream_cleanup_files (MyLogicalRepWorker -> subid , xid );
12201218 }
12211219 else
@@ -1241,7 +1239,7 @@ apply_handle_stream_abort(StringInfo s)
12411239 bool found = false;
12421240 char path [MAXPGPATH ];
12431241
1244- set_apply_error_context_xact (subxid , 0 );
1242+ set_apply_error_context_xact (subxid );
12451243
12461244 subidx = -1 ;
12471245 begin_replication_step ();
@@ -1426,7 +1424,7 @@ apply_handle_stream_commit(StringInfo s)
14261424 errmsg_internal ("STREAM COMMIT message without STREAM STOP" )));
14271425
14281426 xid = logicalrep_read_stream_commit (s , & commit_data );
1429- set_apply_error_context_xact (xid , commit_data . committime );
1427+ set_apply_error_context_xact (xid );
14301428
14311429 elog (DEBUG1 , "received commit for streamed transaction %u" , xid );
14321430
@@ -3648,46 +3646,41 @@ IsLogicalWorker(void)
36483646static void
36493647apply_error_callback (void * arg )
36503648{
3651- StringInfoData buf ;
36523649 ApplyErrorCallbackArg * errarg = & apply_error_callback_arg ;
36533650
36543651 if (apply_error_callback_arg .command == 0 )
36553652 return ;
36563653
3657- initStringInfo (& buf );
3658- appendStringInfo (& buf , _ ("processing remote data during \"%s\"" ),
3659- logicalrep_message_type (errarg -> command ));
3660-
3661- /* append relation information */
3662- if (errarg -> rel )
3663- {
3664- appendStringInfo (& buf , _ (" for replication target relation \"%s.%s\"" ),
3665- errarg -> rel -> remoterel .nspname ,
3666- errarg -> rel -> remoterel .relname );
3667- if (errarg -> remote_attnum >= 0 )
3668- appendStringInfo (& buf , _ (" column \"%s\"" ),
3669- errarg -> rel -> remoterel .attnames [errarg -> remote_attnum ]);
3670- }
3671-
3672- /* append transaction information */
3673- if (TransactionIdIsNormal (errarg -> remote_xid ))
3654+ if (errarg -> rel == NULL )
36743655 {
3675- appendStringInfo (& buf , _ (" in transaction %u" ), errarg -> remote_xid );
3676- if (errarg -> ts != 0 )
3677- appendStringInfo (& buf , _ (" at %s" ),
3678- timestamptz_to_str (errarg -> ts ));
3656+ if (!TransactionIdIsValid (errarg -> remote_xid ))
3657+ errcontext ("processing remote data during \"%s\"" ,
3658+ logicalrep_message_type (errarg -> command ));
3659+ else
3660+ errcontext ("processing remote data during \"%s\" in transaction %u" ,
3661+ logicalrep_message_type (errarg -> command ),
3662+ errarg -> remote_xid );
36793663 }
3680-
3681- errcontext ("%s" , buf .data );
3682- pfree (buf .data );
3664+ else if (errarg -> remote_attnum < 0 )
3665+ errcontext ("processing remote data during \"%s\" for replication target relation \"%s.%s\" in transaction %u" ,
3666+ logicalrep_message_type (errarg -> command ),
3667+ errarg -> rel -> remoterel .nspname ,
3668+ errarg -> rel -> remoterel .relname ,
3669+ errarg -> remote_xid );
3670+ else
3671+ errcontext ("processing remote data during \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %u" ,
3672+ logicalrep_message_type (errarg -> command ),
3673+ errarg -> rel -> remoterel .nspname ,
3674+ errarg -> rel -> remoterel .relname ,
3675+ errarg -> rel -> remoterel .attnames [errarg -> remote_attnum ],
3676+ errarg -> remote_xid );
36833677}
36843678
36853679/* Set transaction information of apply error callback */
36863680static inline void
3687- set_apply_error_context_xact (TransactionId xid , TimestampTz ts )
3681+ set_apply_error_context_xact (TransactionId xid )
36883682{
36893683 apply_error_callback_arg .remote_xid = xid ;
3690- apply_error_callback_arg .ts = ts ;
36913684}
36923685
36933686/* Reset all information of apply error callback */
@@ -3697,5 +3690,5 @@ reset_apply_error_context_info(void)
36973690 apply_error_callback_arg .command = 0 ;
36983691 apply_error_callback_arg .rel = NULL ;
36993692 apply_error_callback_arg .remote_attnum = -1 ;
3700- set_apply_error_context_xact (InvalidTransactionId , 0 );
3693+ set_apply_error_context_xact (InvalidTransactionId );
37013694}
0 commit comments