diff options
author | Kristian Nielsen <knielsen@knielsen-hq.org> | 2015-05-26 12:47:35 +0200 |
---|---|---|
committer | Kristian Nielsen <knielsen@knielsen-hq.org> | 2015-05-26 13:04:15 +0200 |
commit | e5f1e841dc32ccb8e8630876e8073efd778d3efd (patch) | |
tree | d56611270886a591627a8c59ce7747f14a2a6679 /sql/rpl_parallel.cc | |
parent | ef99edf1a87d5234cf0dd8d496f0adfbf4040dad (diff) | |
download | mariadb-git-e5f1e841dc32ccb8e8630876e8073efd778d3efd.tar.gz |
MDEV-8147: Assertion `m_lock_type == 2' failed in handler::ha_close() during parallel replication
When the slave processes the master restart format_description event,
parallel replication needs to complete any prior events before processing
the restart event (which closes temporary tables and such stuff).
This happens in wait_for_workers_idle(), however it was not waiting long
enough. The wait was using wait_for_prior_commit(), but at that points table
can still be open. This lead to assertion in this case.
So change wait_for_workers_idle() to wait until all worker threads have
reached finish_event_group(), at which point all tables should have been
closed.
Diffstat (limited to 'sql/rpl_parallel.cc')
-rw-r--r-- | sql/rpl_parallel.cc | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 99ddde95689..305e8053032 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -168,6 +168,8 @@ finish_event_group(rpl_parallel_thread *rpt, uint64 sub_id, done and also no longer need waiting for. */ entry->last_committed_sub_id= sub_id; + if (entry->need_sub_id_signal) + mysql_cond_broadcast(&entry->COND_parallel_entry); /* Now free any GCOs in which all transactions have committed. */ group_commit_orderer *tmp_gco= rgi->gco; @@ -1894,26 +1896,29 @@ rpl_parallel::wait_for_workers_idle(THD *thd) max_i= domain_hash.records; for (i= 0; i < max_i; ++i) { - bool active; - wait_for_commit my_orderer; + PSI_stage_info old_stage; struct rpl_parallel_entry *e; + int err= 0; e= (struct rpl_parallel_entry *)my_hash_element(&domain_hash, i); mysql_mutex_lock(&e->LOCK_parallel_entry); - if ((active= (e->current_sub_id > e->last_committed_sub_id))) - { - wait_for_commit *waitee= &e->current_group_info->commit_orderer; - my_orderer.register_wait_for_prior_commit(waitee); - thd->wait_for_commit_ptr= &my_orderer; - } - mysql_mutex_unlock(&e->LOCK_parallel_entry); - if (active) + e->need_sub_id_signal= true; + thd->ENTER_COND(&e->COND_parallel_entry, &e->LOCK_parallel_entry, + &stage_waiting_for_workers_idle, &old_stage); + while (e->current_sub_id > e->last_committed_sub_id) { - int err= my_orderer.wait_for_prior_commit(thd); - thd->wait_for_commit_ptr= NULL; - if (err) - return err; + if (thd->check_killed()) + { + thd->send_kill_message(); + err= 1; + break; + } + mysql_cond_wait(&e->COND_parallel_entry, &e->LOCK_parallel_entry); } + e->need_sub_id_signal= false; + thd->EXIT_COND(&old_stage); + if (err) + return err; } return 0; } |