diff --git a/sql/binlog.cc b/sql/binlog.cc index d35e2e36d929..89e9c37e1fb4 100644 --- a/sql/binlog.cc +++ b/sql/binlog.cc @@ -6439,8 +6439,8 @@ bool MYSQL_BIN_LOG::open_existing_binlog(const char *log_name, DBUG_RETURN(1); } - if (!(this->name = - my_strdup(key_memory_MYSQL_LOG_name, log_name, MYF(MY_WME)))) { + my_free(name); + if (!(name = my_strdup(key_memory_MYSQL_LOG_name, log_name, MYF(MY_WME)))) { // NO_LINT_DEBUG sql_print_error("Could not allocate name %s (error %d)", log_name, errno); DBUG_RETURN(1); @@ -6450,6 +6450,8 @@ bool MYSQL_BIN_LOG::open_existing_binlog(const char *log_name, Binlog_ofile::open_existing(m_key_file_log, existing_file, MYF(MY_WME)); if (!binlog_file) goto err; + // release current point before assign + delete m_binlog_file; m_binlog_file = binlog_file.release(); file = mysql_file_open(m_key_file_log, existing_file, O_CREAT | O_WRONLY, diff --git a/sql/log_event.cc b/sql/log_event.cc index 906694a6f20e..f1a3632e36df 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -4676,17 +4676,15 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli) { } int Query_log_event::do_apply_event_worker(Slave_worker *w) { - if (ends_group()) { - // Note: We're using event's future_event_relay_log_pos instead of - // rli->get_event_relay_log_pos() because rli is only updated in - // do_update_pos() which is called after applying the event and we might - // need to use this pos during application (e.g. during commit) - Slave_job_group *ptr_g = w->c_rli->gaq->get_job_group(mts_group_idx); - thd->set_trans_relay_log_pos(ptr_g->group_relay_log_name - ? ptr_g->group_relay_log_name - : w->get_group_relay_log_name(), - future_event_relay_log_pos); - } + // Note: We're using event's future_event_relay_log_pos instead of + // rli->get_event_relay_log_pos() because rli is only updated in + // do_update_pos() which is called after applying the event and we might + // need to use this pos during application (e.g. during commit) + Slave_job_group *ptr_g = w->c_rli->gaq->get_job_group(mts_group_idx); + thd->set_trans_relay_log_pos(ptr_g && ptr_g->group_relay_log_name + ? ptr_g->group_relay_log_name + : w->get_group_relay_log_name(), + future_event_relay_log_pos); return do_apply_event(w, query, q_len); }