From 6a252b5a6aa8f66c5866e84c7d9ee6b3cd4c884e Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Wed, 29 Sep 2021 19:19:38 +0300 Subject: MDEV-26712 row events never reset thd->mem_root but must do that at the end of the statement. A provide template patch is elaborated also to match to the upstream fixes of the very same bug. --- sql/log_event.cc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index c82a721708b..64f212b9f69 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -11722,14 +11722,18 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) } #endif /* WITH_WSREP && HAVE_QUERY_CACHE */ - if (unlikely(get_flags(STMT_END_F) && - (error= rows_event_stmt_cleanup(rgi, thd)))) - slave_rows_error_report(ERROR_LEVEL, - thd->is_error() ? 0 : error, - rgi, thd, table, - get_type_str(), - RPL_LOG_NAME, log_pos); - DBUG_RETURN(error); + if (unlikely(get_flags(STMT_END_F))) + { + if ((error= rows_event_stmt_cleanup(rgi, thd))) + slave_rows_error_report(ERROR_LEVEL, + thd->is_error() ? 0 : error, + rgi, thd, table, + get_type_str(), + RPL_LOG_NAME, log_pos); + if (thd->slave_thread) + free_root(thd->mem_root, MYF(MY_KEEP_PREALLOC)); + } + DBUG_RETURN(error); err: restore_empty_query_table_list(thd->lex); -- cgit v1.2.1