From 5bc3918c764a134a6c45beb6d322b9fcc862d1f7 Mon Sep 17 00:00:00 2001 From: yuxianjiang Date: Tue, 5 Sep 2023 15:26:44 +0800 Subject: [PATCH] Problem ======= After turning on log_replica_updates, when the source event is logged to replica binlog, the thread_id is changed. On 5.7, the thread id is the same after writing down to replica binlog. After starting replication, if the first event is in row format, the source binlog event's thread_id is replication worker thread's thread_id. The first query event will replace the work thread's THD's pseudo_thread_id with its own. But the following row format event will always use this thread id until next query event. Solution ======== Restore to 5.7 implementation. For every query log event, use the event's thread id. --- sql/log_event.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index dcad777..dee0cde 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5103,13 +5103,13 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, thd->is_slave_error = true; return true; } - thd->variables.pseudo_thread_id = thread_id; // for temp tables attach_temp_tables_worker(thd, rli); return false; }; thd->rpl_thd_ctx.post_filters_actions().push_back(f); } + thd->variables.pseudo_thread_id = thread_id; // for temp tables thd->set_time(&(common_header->when)); thd->set_query(query_arg, q_len_arg); thd->set_query_for_display(query_arg, q_len_arg); -- 1.8.3.1