summaryrefslogtreecommitdiff
path: root/sql/rpl_parallel.cc
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2013-12-13 14:26:51 +0100
committerunknown <knielsen@knielsen-hq.org>2013-12-13 14:26:51 +0100
commitdbfe5f4774cf35283f7c7378d25fe881c00103c2 (patch)
tree6bda414f61cd9c29b376ef3a3b466f4febd3a387 /sql/rpl_parallel.cc
parentb7ae65ef86636e986594d8e44dec83a83311977c (diff)
downloadmariadb-git-dbfe5f4774cf35283f7c7378d25fe881c00103c2.tar.gz
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.
Diffstat (limited to 'sql/rpl_parallel.cc')
-rw-r--r--sql/rpl_parallel.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index ff2ad84e037..91aa36abc52 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -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;