# # Test Galera as a slave to a MySQL master using GTIDs # --source include/have_innodb.inc --source include/galera_cluster.inc --source include/have_log_bin.inc # As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it # we open the node_3 connection here --connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 --connection node_1 SET global wsrep_on=OFF; RESET MASTER; SET global wsrep_on=ON; --connection node_3 RESET MASTER; --connection node_2 SET global wsrep_on=OFF; RESET MASTER; SET global wsrep_on=ON; --disable_query_log --eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_3, MASTER_USER='root'; --enable_query_log START SLAVE; --connection node_3 CREATE SCHEMA test1; CREATE SCHEMA test2; USE test1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB; USE test2; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB; # # First , some autocommit stuff # # Simple inserts INSERT INTO test1.t1 (f1) VALUES (1); INSERT INTO test2.t1 (f1) VALUES (1); INSERT INTO test1.t1 (f1) VALUES (2); INSERT INTO test2.t1 (f1) VALUES (2); INSERT INTO test1.t1 (f1) VALUES (3); INSERT INTO test2.t1 (f1) VALUES (3); # Update that only covers test2.t1 UPDATE test2.t1 SET test2.t1.f2 = 'cde'; # Multi-table UPDATE UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz'; # Multi-table DELETE DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3; # # Multi-statement transactions # # Transaction which is not replicated at all SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO test2.t1 (f1) VALUES (999); INSERT INTO test2.t1 (f1) VALUES (9999); COMMIT; # Transaction that is completely replicated START TRANSACTION; INSERT INTO test1.t1 (f1) VALUES (111); INSERT INTO test1.t1 (f1) VALUES (222); COMMIT; # Transaction that is partially replicated START TRANSACTION; INSERT INTO test1.t1 (f1) VALUES (333); INSERT INTO test2.t1 (f1) VALUES (99999); COMMIT; # # Make sure binary logs and gtid_executed strings are equal # --sleep 2 --connection node_2 --let $effective_uuid = `SELECT LEFT(@@global.gtid_current_pos, 36)` --let $gtid_executed_node2 = `SELECT @@global.gtid_current_pos;` --replace_result $effective_uuid --replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/ SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256; --connection node_1 --disable_query_log --eval SELECT '$gtid_executed_node2' = @@global.gtid_current_pos AS gtid_executed_equal; --enable_query_log --replace_result $effective_uuid --replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/ SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256; # # Final consistency checks # --let $diff_servers = 1 2 --source include/diff_servers.inc --connection node_1 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc SELECT COUNT(*) = 2 FROM test1.t1 WHERE f1 IN (1,2); SELECT COUNT(*) = 3 FROM test1.t1 WHERE f1 IN (111,222,333); SELECT COUNT(*) = 2 FROM test1.t1 WHERE f2 = 'klm'; --error 1049 USE test2; # # Cleanup # --connection node_3 DROP SCHEMA test1; DROP SCHEMA test2; --sleep 1 --connection node_1 --let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc --connection node_2 --let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc STOP SLAVE; RESET SLAVE ALL;