[PATCH] Fix redundant ER_PRIOR_COMMIT_FAILED in parallel replication

wait_for_prior_commit() can be called multiple times per event group, only do my_error() the first time the call fails. Remove redundant set_overwrite_status() calls. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org> --- sql/rpl_parallel.cc | 8 -------- sql/sql_class.cc | 12 ++++++++++++ sql/sql_class.h | 5 +++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index f2633c3e1d1..502a0501553 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -157,8 +157,6 @@ finish_event_group(rpl_parallel_thread *rpt, uint64 sub_id, wait_for_commit *wfc= &rgi->commit_orderer; int err; - thd->get_stmt_da()->set_overwrite_status(true); - if (unlikely(rgi->worker_error)) { /* @@ -317,10 +315,6 @@ finish_event_group(rpl_parallel_thread *rpt, uint64 sub_id, wait_for_pending_deadlock_kill(thd, rgi); thd->clear_error(); thd->reset_killed(); - /* - Would do thd->get_stmt_da()->set_overwrite_status(false) here, but - reset_diagnostics_area() already does that. - */ thd->get_stmt_da()->reset_diagnostics_area(); wfc->wakeup_subsequent_commits(rgi->worker_error); } @@ -1567,9 +1561,7 @@ handle_rpl_parallel_thread(void *arg) else { delete qev->ev; - thd->get_stmt_da()->set_overwrite_status(true); err= thd->wait_for_prior_commit(); - thd->get_stmt_da()->set_overwrite_status(false); } end_of_group= diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b20e1052e30..938ac5f6bd1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -8365,6 +8365,18 @@ wait_for_commit::wait_for_prior_commit2(THD *thd, bool allow_kill) } +void +wait_for_commit::prior_commit_error(THD *thd) +{ + /* + Only raise a "prior commit failed" error if we didn't already raise + an error. + */ + if (!thd->get_stmt_da()->is_set()) + my_error(ER_PRIOR_COMMIT_FAILED, MYF(0)); +} + + /* Wakeup anyone waiting for us to have committed. diff --git a/sql/sql_class.h b/sql/sql_class.h index 4cee31b296e..69b021cd41d 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2398,8 +2398,8 @@ struct wait_for_commit return wait_for_prior_commit2(thd, allow_kill); else { - if (wakeup_error) - my_error(ER_PRIOR_COMMIT_FAILED, MYF(0)); + if (unlikely(wakeup_error)) + prior_commit_error(thd); return wakeup_error; } } @@ -2450,6 +2450,7 @@ struct wait_for_commit void wakeup(int wakeup_error); int wait_for_prior_commit2(THD *thd, bool allow_kill); + void prior_commit_error(THD *thd); void wakeup_subsequent_commits2(int wakeup_error); void unregister_wait_for_prior_commit2(); -- 2.39.5
participants (1)
-
Kristian Nielsen