Skip to content

Commit 74b1af1

Browse files
committed
Merge branch 'tmp' into tmp-10.0
Conflicts: sql/slave.cc
2 parents 3730d8a + 06b2e32 commit 74b1af1

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
@@ -929,6 +929,8 @@ a
929929
31
930930
32
931931
SET sql_slave_skip_counter= 1;
932+
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.
933+
include/stop_slave_io.inc
932934
include/start_slave.inc
933935
include/sync_with_master_gtid.inc
934936
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
@@ -1423,6 +1423,7 @@ SELECT * FROM t6 ORDER BY a;
14231423

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

14281429
--connection server_2
@@ -1438,6 +1439,7 @@ SET sql_log_bin= 1;
14381439

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

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

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
@@ -7108,7 +7108,7 @@ ER_PRIOR_COMMIT_FAILED
71087108
ER_IT_IS_A_VIEW 42S02
71097109
eng "'%-.192s' is a view"
71107110
ER_SLAVE_SKIP_NOT_IN_GTID
7111-
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."
7111+
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."
71127112
ER_TABLE_DEFINITION_TOO_BIG
71137113
eng "The definition for table %`s is too big"
71147114
ER_PLUGIN_INSTALLED

sql/slave.cc

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

45414541
serial_rgi->gtid_sub_id= 0;
45424542
serial_rgi->gtid_pending= false;
4543-
if (mi->using_gtid != Master_info::USE_GTID_NO)
4544-
{
4545-
/*
4546-
We initialize the relay log state from the know starting position.
4547-
It will then be updated as required by GTID and GTID_LIST events found
4548-
while applying events read from relay logs.
4549-
*/
4550-
rli->relay_log_state.load(rpl_global_gtid_slave_state);
4551-
}
45524543
rli->gtid_skip_flag = GTID_SKIP_NOT;
45534544
if (init_relay_log_pos(rli,
45544545
rli->group_relay_log_name,
@@ -4804,6 +4795,7 @@ log '%s' at position %s, relay log '%s' position: %s%s", RPL_LOG_NAME,
48044795
}
48054796
strmake_buf(rli->group_relay_log_name, ir->name);
48064797
rli->group_relay_log_pos= BIN_LOG_HEADER_SIZE;
4798+
rli->relay_log_state.load(ir->relay_log_state, ir->relay_log_state_count);
48074799
}
48084800
}
48094801
}

sql/sys_vars.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4331,6 +4331,29 @@ static bool update_slave_skip_counter(sys_var *self, THD *thd, Master_info *mi)
43314331
mi->connection_name.str);
43324332
return true;
43334333
}
4334+
if (mi->using_gtid != Master_info::USE_GTID_NO &&
4335+
opt_slave_parallel_threads > 0)
4336+
{
4337+
ulong domain_count;
4338+
mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state);
4339+
domain_count= rpl_global_gtid_slave_state->count();
4340+
mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state);
4341+
if (domain_count > 1)
4342+
{
4343+
/*
4344+
With domain-based parallel replication, the slave position is
4345+
multi-dimensional, so the relay log position is not very meaningful.
4346+
It might not even correspond to the next GTID to execute in _any_
4347+
domain (the case after error stop). So slave_skip_counter will most
4348+
likely not do what the user intends. Instead give an error, with a
4349+
suggestion to instead set @@gtid_slave_pos past the point of error;
4350+
this works reliably also in the case of multiple domains.
4351+
*/
4352+
my_error(ER_SLAVE_SKIP_NOT_IN_GTID, MYF(0));
4353+
return true;
4354+
}
4355+
}
4356+
43344357
/* The value was stored temporarily in thd */
43354358
mi->rli.slave_skip_counter= thd->variables.slave_skip_counter;
43364359
return false;

0 commit comments

Comments
 (0)