From 385780f571c752e871f806997acad4fb28b9085c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 May 2013 11:41:25 +0200 Subject: [PATCH] MDEV-4485: Master did not allow slave to connect from the very start (empty GTID pos) if GTIDs from other multi_source master was present The idea in the code was to protect the user that tries to connect a slave to a master with completely different domains than what was intended. If none of the domains in the start position are present at all in the master binlog, we gave an error. However, this is a stupid idea. Because when a slave connects to a master to start replication from the very start of binlogs - such as when setting up new master->slave servers from scratch - there will be just this situation, the requested slave position is empty for all the domains in the master's binlog. So the code that gives this error is wrong, and the solution is simply to remove it. --- .../suite/rpl/r/rpl_gtid_mdev4485.result | 15 +++++++ mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf | 18 +++++++++ mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test | 40 +++++++++++++++++++ sql/sql_repl.cc | 17 -------- 4 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_gtid_mdev4485.result create mode 100644 mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf create mode 100644 mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test diff --git a/mysql-test/suite/rpl/r/rpl_gtid_mdev4485.result b/mysql-test/suite/rpl/r/rpl_gtid_mdev4485.result new file mode 100644 index 00000000000..34efd43f81b --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_mdev4485.result @@ -0,0 +1,15 @@ +include/rpl_init.inc [topology=1->3] +*** MDEV-4485. Master did not allow slave to connect from the very start (empty GTID pos) if GTIDs from other multi_source master was present *** +create table t1 (i int); +create table t2 (i int); +set default_master_connection = 'm2'; +change master to master_host='127.0.0.1', master_port=SERVER_MYPORT_2, master_user='root', master_use_gtid=slave_pos; +include/start_slave.inc +insert into t2 values (1); +drop table t1; +drop table t2; +set default_master_connection = 'm2'; +include/stop_slave.inc +RESET SLAVE ALL; +set default_master_connection = ''; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf b/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf new file mode 100644 index 00000000000..fccef215ccc --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.cnf @@ -0,0 +1,18 @@ +!include suite/rpl/rpl_1slave_base.cnf +!include include/default_client.cnf + +[mysqld.1] +log-slave-updates +gtid-domain-id=1 + +[mysqld.2] +log-slave-updates +gtid-domain-id=2 + +[mysqld.3] +log-slave-updates +gtid-domain-id=3 + +[ENV] +SERVER_MYPORT_3= @mysqld.3.port +SERVER_MYSOCK_3= @mysqld.3.socket diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test b/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test new file mode 100644 index 00000000000..4a0c76d5c1d --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev4485.test @@ -0,0 +1,40 @@ +--let $rpl_topology= 1->3 +--source include/rpl_init.inc + +--echo *** MDEV-4485. Master did not allow slave to connect from the very start (empty GTID pos) if GTIDs from other multi_source master was present *** + +--connection server_1 +create table t1 (i int); + +--connection server_2 +create table t2 (i int); + +--connection server_3 + +set default_master_connection = 'm2'; +--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2 +eval change master to master_host='127.0.0.1', master_port=$SERVER_MYPORT_2, master_user='root', master_use_gtid=slave_pos; +--source include/start_slave.inc + +--connection server_2 +insert into t2 values (1); +--save_master_pos + +--connection server_3 +--sync_with_master 0,'m2' + +--connection server_1 +drop table t1; + +--connection server_2 +drop table t2; + +--connection server_3 +--sync_with_master 0,'m2' +set default_master_connection = 'm2'; +--source include/stop_slave.inc +RESET SLAVE ALL; +set default_master_connection = ''; + +--connection server_1 +--source include/rpl_end.inc diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 5ed73bf81f3..fd9ead71472 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -901,8 +901,6 @@ check_slave_start_position(THD *thd, slave_connection_state *st, rpl_gtid **delete_list= NULL; uint32 delete_idx= 0; bool slave_state_loaded= false; - uint32 missing_domains= 0; - rpl_gtid missing_domain_gtid; for (i= 0; i < st->hash.records; ++i) { @@ -943,14 +941,7 @@ check_slave_start_position(THD *thd, slave_connection_state *st, We do not have anything in this domain, neither in the binlog nor in the slave state. So we are probably one master in a multi-master setup, and this domain is served by a different master. - - This is not an error, however if we are missing _all_ domains - requested by the slave, then we still give error (below, after - the loop). */ - if (!missing_domains) - missing_domain_gtid= *slave_gtid; - ++missing_domains; continue; } @@ -1043,14 +1034,6 @@ check_slave_start_position(THD *thd, slave_connection_state *st, } } - if (missing_domains == st->hash.records && missing_domains > 0) - { - *errormsg= "Requested slave GTID state not found in binlog"; - *error_gtid= missing_domain_gtid; - err= ER_GTID_POSITION_NOT_FOUND_IN_BINLOG; - goto end; - } - /* Do any delayed deletes from the hash. */ if (delete_list) {