mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-5363: Make parallel replication waits killable
Add a test case for killing a waiting query in parallel replication. Fix several bugs found: - We should not wakeup_subsequent_commits() in ha_rollback_trans(), since we do not know the right wakeup_error() to give. - When a wait_for_prior_commit() is killed, we must unregister from the waitee so we do not race and get an extra (non-kill) wakeup. - We need to deal with error propagation correctly in queue_for_group_commit when one thread is killed. - Fix one locking issue in queue_for_group_commit(), we could unlock the waitee lock too early and this end up processing wakeup() with insufficient locking. - Fix Xid_log_event::do_apply_event; if commit fails it must not update the in-memory @@gtid_slave_pos state. - Fix and cleanup some things in the rpl_parallel.cc error handling. - Add a missing check for killed in the slave sql driver thread, to avoid a race.
This commit is contained in:
@@ -24,7 +24,7 @@ static int
|
||||
rpt_handle_event(rpl_parallel_thread::queued_event *qev,
|
||||
struct rpl_parallel_thread *rpt)
|
||||
{
|
||||
int err __attribute__((unused));
|
||||
int err;
|
||||
rpl_group_info *rgi= qev->rgi;
|
||||
Relay_log_info *rli= rgi->rli;
|
||||
THD *thd= rgi->thd;
|
||||
@@ -172,6 +172,18 @@ finish_event_group(THD *thd, int err, uint64 sub_id,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
signal_error_to_sql_driver_thread(THD *thd, rpl_group_info *rgi)
|
||||
{
|
||||
rgi->is_error= true;
|
||||
rgi->cleanup_context(thd, true);
|
||||
rgi->rli->abort_slave= true;
|
||||
mysql_mutex_lock(rgi->rli->relay_log.get_log_lock());
|
||||
mysql_mutex_unlock(rgi->rli->relay_log.get_log_lock());
|
||||
rgi->rli->relay_log.signal_update();
|
||||
}
|
||||
|
||||
|
||||
pthread_handler_t
|
||||
handle_rpl_parallel_thread(void *arg)
|
||||
{
|
||||
@@ -304,10 +316,8 @@ handle_rpl_parallel_thread(void *arg)
|
||||
{
|
||||
/* The thread got a kill signal. */
|
||||
thd->send_kill_message();
|
||||
rgi->is_error= true;
|
||||
slave_output_error_info(rgi->rli, thd);
|
||||
rgi->cleanup_context(thd, true);
|
||||
rgi->rli->abort_slave= true;
|
||||
signal_error_to_sql_driver_thread(thd, rgi);
|
||||
}
|
||||
rgi->wait_start_sub_id= 0; /* No need to check again. */
|
||||
}
|
||||
@@ -363,10 +373,8 @@ handle_rpl_parallel_thread(void *arg)
|
||||
|
||||
if (err)
|
||||
{
|
||||
rgi->is_error= true;
|
||||
slave_output_error_info(rgi->rli, thd);
|
||||
rgi->cleanup_context(thd, true);
|
||||
rgi->rli->abort_slave= true;
|
||||
signal_error_to_sql_driver_thread(thd, rgi);
|
||||
}
|
||||
if (end_of_group)
|
||||
{
|
||||
@@ -405,11 +413,9 @@ handle_rpl_parallel_thread(void *arg)
|
||||
half-processed event group.
|
||||
*/
|
||||
mysql_mutex_unlock(&rpt->LOCK_rpl_thread);
|
||||
group_rgi->is_error= true;
|
||||
finish_event_group(thd, 1, group_rgi->gtid_sub_id,
|
||||
group_rgi->parallel_entry, &group_rgi->commit_orderer);
|
||||
group_rgi->cleanup_context(thd, true);
|
||||
group_rgi->rli->abort_slave= true;
|
||||
signal_error_to_sql_driver_thread(thd, group_rgi);
|
||||
in_event_group= false;
|
||||
delete group_rgi;
|
||||
group_rgi= NULL;
|
||||
|
Reference in New Issue
Block a user