Skip to content

Commit 2f88b14

Browse files
committed
Merge branch 'tmp' into tmp-10.1
Conflicts: sql/slave.cc
2 parents 55d61ec + 06b2e32 commit 2f88b14

File tree

6 files changed

+36
-10
lines changed

6 files changed

+36
-10
lines changed

mysql-test/suite/rpl/r/rpl_parallel.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,8 @@ a
930930
31
931931
32
932932
SET sql_slave_skip_counter= 1;
933+
ERROR HY000: When using parallel replication and GTID with multiple replication domains, @@sql_slave_skip_counter can not be used. Instead, setting @@gtid_slave_pos explicitly can be used to skip to after a given GTID position.
934+
include/stop_slave_io.inc
933935
include/start_slave.inc
934936
include/sync_with_master_gtid.inc
935937
SELECT * FROM t2 WHERE a >= 30 ORDER BY a;

mysql-test/suite/rpl/t/rpl_parallel.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@ SELECT * FROM t6 ORDER BY a;
14221422

14231423
--connection server_1
14241424
INSERT INTO t2 VALUES (31);
1425+
--let $gtid1= `SELECT @@LAST_GTID`
14251426
--source include/save_master_gtid.inc
14261427

14271428
--connection server_2
@@ -1437,6 +1438,7 @@ SET sql_log_bin= 1;
14371438

14381439
--connection server_1
14391440
INSERT INTO t2 VALUES (32);
1441+
--let $gtid2= `SELECT @@LAST_GTID`
14401442
# Rotate the binlog; the bug is triggered when the master binlog file changes
14411443
# after the event group that causes the duplicate key error.
14421444
FLUSH LOGS;
@@ -1469,7 +1471,12 @@ START SLAVE SQL_THREAD;
14691471
SELECT * FROM t2 WHERE a >= 30 ORDER BY a;
14701472

14711473
# Skip the duplicate error, so we can proceed.
1474+
--error ER_SLAVE_SKIP_NOT_IN_GTID
14721475
SET sql_slave_skip_counter= 1;
1476+
--source include/stop_slave_io.inc
1477+
--disable_query_log
1478+
eval SET GLOBAL gtid_slave_pos = REPLACE(@@gtid_slave_pos, "$gtid1", "$gtid2");
1479+
--enable_query_log
14731480
--source include/start_slave.inc
14741481
--source include/sync_with_master_gtid.inc
14751482

sql/rpl_rli.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ Failed to open the existing relay log info file '%s' (errno %d)",
389389
if (rli->is_relay_log_recovery && init_recovery(rli->mi, &msg))
390390
goto err;
391391

392+
rli->relay_log_state.load(rpl_global_gtid_slave_state);
392393
if (init_relay_log_pos(rli,
393394
rli->group_relay_log_name,
394395
rli->group_relay_log_pos,
@@ -1148,6 +1149,7 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
11481149
error=1;
11491150
goto err;
11501151
}
1152+
rli->relay_log_state.load(rpl_global_gtid_slave_state);
11511153
if (!just_reset)
11521154
{
11531155
/* Save name of used relay log file */

sql/share/errmsg-utf8.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7106,7 +7106,7 @@ ER_PRIOR_COMMIT_FAILED
71067106
ER_IT_IS_A_VIEW 42S02
71077107
eng "'%-.192s' is a view"
71087108
ER_SLAVE_SKIP_NOT_IN_GTID
7109-
eng "When using GTID, @@sql_slave_skip_counter can not be used. Instead, setting @@gtid_slave_pos explicitly can be used to skip to after a given GTID position."
7109+
eng "When using parallel replication and GTID with multiple replication domains, @@sql_slave_skip_counter can not be used. Instead, setting @@gtid_slave_pos explicitly can be used to skip to after a given GTID position."
71107110
ER_TABLE_DEFINITION_TOO_BIG
71117111
eng "The definition for table %`s is too big"
71127112
ER_PLUGIN_INSTALLED

sql/slave.cc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4607,15 +4607,6 @@ pthread_handler_t handle_slave_sql(void *arg)
46074607

46084608
serial_rgi->gtid_sub_id= 0;
46094609
serial_rgi->gtid_pending= false;
4610-
if (mi->using_gtid != Master_info::USE_GTID_NO)
4611-
{
4612-
/*
4613-
We initialize the relay log state from the know starting position.
4614-
It will then be updated as required by GTID and GTID_LIST events found
4615-
while applying events read from relay logs.
4616-
*/
4617-
rli->relay_log_state.load(rpl_global_gtid_slave_state);
4618-
}
46194610
rli->gtid_skip_flag = GTID_SKIP_NOT;
46204611
if (init_relay_log_pos(rli,
46214612
rli->group_relay_log_name,
@@ -4886,6 +4877,7 @@ pthread_handler_t handle_slave_sql(void *arg)
48864877
}
48874878
strmake_buf(rli->group_relay_log_name, ir->name);
48884879
rli->group_relay_log_pos= BIN_LOG_HEADER_SIZE;
4880+
rli->relay_log_state.load(ir->relay_log_state, ir->relay_log_state_count);
48894881
}
48904882
}
48914883
}

sql/sys_vars.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4489,6 +4489,29 @@ static bool update_slave_skip_counter(sys_var *self, THD *thd, Master_info *mi)
44894489
mi->connection_name.str);
44904490
return true;
44914491
}
4492+
if (mi->using_gtid != Master_info::USE_GTID_NO &&
4493+
opt_slave_parallel_threads > 0)
4494+
{
4495+
ulong domain_count;
4496+
mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state);
4497+
domain_count= rpl_global_gtid_slave_state->count();
4498+
mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state);
4499+
if (domain_count > 1)
4500+
{
4501+
/*
4502+
With domain-based parallel replication, the slave position is
4503+
multi-dimensional, so the relay log position is not very meaningful.
4504+
It might not even correspond to the next GTID to execute in _any_
4505+
domain (the case after error stop). So slave_skip_counter will most
4506+
likely not do what the user intends. Instead give an error, with a
4507+
suggestion to instead set @@gtid_slave_pos past the point of error;
4508+
this works reliably also in the case of multiple domains.
4509+
*/
4510+
my_error(ER_SLAVE_SKIP_NOT_IN_GTID, MYF(0));
4511+
return true;
4512+
}
4513+
}
4514+
44924515
/* The value was stored temporarily in thd */
44934516
mi->rli.slave_skip_counter= thd->variables.slave_skip_counter;
44944517
return false;

0 commit comments

Comments
 (0)