summaryrefslogtreecommitdiff
path: root/sql/rpl_gtid.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2017-08-09 23:54:16 +0300
committerSergei Golubchik <serg@mariadb.org>2017-08-24 01:05:54 +0200
commitf753480c726c5c8137cb2f87cc3bc71e8d535098 (patch)
treeb6b669963de286d8fbcbe86d8b062bad9ebd1f20 /sql/rpl_gtid.cc
parente208100d448acea3d9af90d7fd8934b49b15da31 (diff)
downloadmariadb-git-f753480c726c5c8137cb2f87cc3bc71e8d535098.tar.gz
Fixed assert when running rpl.rpl_parallel_partition
The problem was that select_gtid_pos_table() was called by IO thread without mutex protection.
Diffstat (limited to 'sql/rpl_gtid.cc')
-rw-r--r--sql/rpl_gtid.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
index f746496993c..d58a2ea4d3e 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -578,7 +578,7 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id,
void **out_hton)
{
TABLE_LIST tlist;
- int err= 0;
+ int err= 0, not_sql_thread;
bool table_opened= false;
TABLE *table;
list_element *delete_list= 0, *next, *cur, **next_ptr_ptr, **best_ptr_ptr;
@@ -606,7 +606,25 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id,
if (!in_statement)
thd->reset_for_next_command();
+
+ /*
+ Only the SQL thread can call select_gtid_pos_table without a mutex
+ Other threads needs to use a mutex and take into account that the
+ result may change during execution, so we have to make a copy.
+ */
+
+ if ((not_sql_thread= (thd->system_thread != SYSTEM_THREAD_SLAVE_SQL)))
+ mysql_mutex_lock(&LOCK_slave_state);
select_gtid_pos_table(thd, &gtid_pos_table_name);
+ if (not_sql_thread)
+ {
+ LEX_CSTRING *tmp= thd->make_clex_string(gtid_pos_table_name.str,
+ gtid_pos_table_name.length);
+ mysql_mutex_unlock(&LOCK_slave_state);
+ if (!tmp)
+ DBUG_RETURN(1);
+ gtid_pos_table_name= *tmp;
+ }
DBUG_EXECUTE_IF("gtid_inject_record_gtid",
{