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>
Reviewed-by: Monty <monty@mariadb.org>
This commit is contained in:
Kristian Nielsen 2025-03-08 11:11:58 +01:00
parent eef94c9d46
commit 2641409731
3 changed files with 21 additions and 10 deletions

View File

@ -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=

View File

@ -8365,6 +8365,24 @@ end:
}
void
wait_for_commit::prior_commit_error(THD *thd)
{
/*
Only raise a "prior commit failed" error if we didn't already raise
an error.
The ER_PRIOR_COMMIT_FAILED is just an internal mechanism to ensure that a
transaction does not commit successfully if a prior commit failed, so that
the parallel replication worker threads stop in an orderly fashion when
one of them get an error. Thus, if another worker already got another real
error, overriding it with ER_PRIOR_COMMIT_FAILED is not useful.
*/
if (!thd->get_stmt_da()->is_set())
my_error(ER_PRIOR_COMMIT_FAILED, MYF(0));
}
/*
Wakeup anyone waiting for us to have committed.

View File

@ -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();